create or replace function decrypt_des(p_text varchar2,p_key varchar2) return varchar2 is
v_text varchar2(2000);
begin
dbms_obfuscation_toolkit.DESDECRYPT(input_string => UTL_RAW.CAST_TO_varchar2(p_text),key_string =>p_key, decrypted_string=> v_text);
v_text := rtrim(v_text,chr(0));
dbms_output.put_line(v_text);
return v_text;
end;
(3)MD5加密函数
CREATE OR REPLACE FUNCTION MD5(passwd IN VARCHAR2)
RETURN VARCHAR2
IS
retval varchar2(32);
BEGIN
retval := utl_raw.cast_to_raw(DBMS_OBFUSCATION_TOOLKIT.MD5(INPUT_STRING => passwd)) ;
RETURN retval;
END;
(4)函数使用示例
DES加密: update tb_salarysign_staff s set s.staffpwd =encrypt_des(s.staffpwd, 'test#5&124*!de');
DES解密:select decrypt_des(s.staffpwd, 'test#5&124*!de') from tb_salarysign_staff s
MD5加密: update tb_salarysign_staff s set s.staffpwd = md5(s.staffpwd); PS:关于加密运算,这里再为大家提供几款比较实用的工具供大家参考使用: MD5在线加密工具:
https://tools.uoften.com/password/CreateMD5Password 在线散列/哈希算法加密工具:
https://tools.uoften.com/password/hash_encrypt 在线MD5/hash/SHA-1/SHA-2/SHA-256/SHA-512/SHA-3/RIPEMD-160加密工具:
https://tools.uoften.com/password/hash_md5_sha 在线sha1/sha224/sha256/sha384/sha512加密工具:
https://tools.uoften.com/password/sha_encode