利用dbms對數據進行加密的方法
1.首先,在數據庫中新建一個test表;
drop table test;
create table test(
userid varchar2(50) primary key,
password varchar2(64),
encrypted varchar2(64)
);
2.test表新建好后,向表中添加數據;
insert into test values ('user1','user1234',null);
3.最后,數據添加好后,執行以下dbms命令即可對數據進行加密;
FUNCTION DECRYPT_3KEY_MODE (
iValue in raw, iMode in pls_integer
)
return varchar2
as
vDecrypted varchar2(4000);
rawkey raw(240) := '';
begin
rawkey := GEN_RAW_KEY(iKey);
-- decrypt input string
vDecrypted := dbms_obfuscation_toolkit.des3decrypt (
UTL_RAW.CAST_TO_VARCHAR2(iValue)
, key_string => rawkey
, which => iMode
);
return vDecrypted;
end;