利用dbms对数据进行加密的方法
首先,在数据库中新建一个test表;
drop table test;
create table test(
userid varchar2(50) primary key,
password varchar2(64),
encrypted varchar2(64)
);
test表新建好后,向表中添加数据;
insert into test values ('user1','user1234',null);
最后,数据添加好后,执行以下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;