1.新建存储过程对数据进行加密
CREATE OR REPLACE PROCEDURE Encrypt_admin(adminNAME varchar2)
is
keyString VARCHAR2(8) := 'czfafeng';
encryptedString VARCHAR2(2048);
pwdString VARCHAR2(2048);
BEGIN
select ADMIN_PWD into pwdString
from admin
where ADMIN_NAME = adminNAME;
dbms_obfuscation_toolkit.desencrypt(
input_string => pwdString,
key_string => keyString,
encrypted_string => encryptedString);
update admin set ADMIN_PWD = encryptedString
where ADMIN_NAME = adminNAME;
commit;
END;
2.调用加密过程
begin
Encrypt_admin('afeng');
end;
3.新建存储过程对数据进行解密
CREATE OR REPLACE PROCEDURE decrypt_admin(adminNAME varchar2)
is
keyString VARCHAR2(8) := 'czfafeng';
decryptedString VARCHAR2(2048);
pwdString VARCHAR2(2048);
BEGIN
select ADMIN_PWD into pwdString
from admin
where ADMIN_NAME = adminNAME;
dbms_obfuscation_toolkit.DESDecrypt(
input_string => pwdString,
key_string => keyString,
decrypted_string => decryptedString);
update admin set ADMIN_PWD = decryptedString
where ADMIN_NAME = adminNAME;
commit;
END;
4.调用解密过程
begin
decrypt_admin('afeng');
end;
网友评论