----权限设置
grant execute on DBMS_CRYPTO to username;
---------加密
create or replace function encrypt256(v_input varchar2) return raw
is
v_result raw(1999);
c_key char(32) := '1q2wa3es4rz5tx6ycD*UF8tif9ogjen2';
begin
v_result := sys.DBMS_CRYPTO.ENCRYPT(
UTL_I18N.STRING_TO_RAW(v_input, 'AL32UTF8'),
sys.DBMS_CRYPTO.ENCRYPT_AES256+sys.DBMS_CRYPTO.CHAIN_CBC+sys.DBMS_CRYPTO.PAD_PKCS5,
UTL_I18N.STRING_TO_RAW(c_key, 'AL32UTF8'));
return v_result;
end;
-----------解密
create or replace function decrypt256(v_input raw) return varchar2
is
v_result raw(1999);
c_key char(32) := '1q2wa3es4rz5tx6ycD*UF8tif9ogjen2';
begin
v_result := SYS.DBMS_CRYPTO.DECRYPT(
v_input,
SYS.DBMS_CRYPTO.ENCRYPT_AES256+SYS.DBMS_CRYPTO.CHAIN_CBC+SYS.DBMS_CRYPTO.PAD_PKCS5,
UTL_I18N.STRING_TO_RAW(c_key, 'AL32UTF8'));
return UTL_I18N.RAW_TO_CHAR(v_result, 'AL32UTF8');
end;
----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;
分享名称:oracle数据库加密脚本
本文URL:
http://cxhlcq.com/article/jgdpjc.html