美文网首页
oracle通过base64对数据进行加密解密

oracle通过base64对数据进行加密解密

作者: JX灬君 | 来源:发表于2021-07-12 13:34 被阅读0次

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;

相关文章

网友评论

      本文标题:oracle通过base64对数据进行加密解密

      本文链接:https://www.haomeiwen.com/subject/pebgultx.html