利用dbms對數(shù)據(jù)進行加密的方法
1.首先,在數(shù)據(jù)庫中新建一個test表;
drop table test;
create table test(
userid varchar2(50) primary key,
password varchar2(64),
encrypted varchar2(64)
);
2.test表新建好后,向表中添加數(shù)據(jù);
insert into test values ('user1','user1234',null);
3.最后,數(shù)據(jù)添加好后,執(zhí)行以下dbms命令即可對數(shù)據(jù)進行加密;
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;