SELECT DBMS_OBFUSCATION_TOOLKIT.MD5(input => utl_raw.cast_to_raw('tg')) a,
DBMS_OBFUSCATION_TOOLKIT.MD5(input => utl_raw.cast_to_raw('123456')) b,
DBMS_OBFUSCATION_TOOLKIT.MD5(input_string => 'tg') aa,
DBMS_OBFUSCATION_TOOLKIT.MD5(input_string => '123456') bb
FROMdual;
md5有二种方式:
1,输入raw,输出raw
2,输入varchar2,输出varchar2
如果使用varchar2,则bgk扩展unicode时可能出现异常(如果使用多重md5加密),for example:
FUNCTION EncryptPWD(p_User VARCHAR2, p_Pwd VARCHAR2) RETURNVARCHAR2IS
v_PwdVARCHAR2(60) := DBMS_OBFUSCATION_TOOLKIT.MD5(input_string => p_Pwd);
v_User VARCHAR2(60) := DBMS_OBFUSCATION_TOOLKIT.MD5(input_string => upper(p_User));
v_CmbVARCHAR2(60);
BEGIN
IF p_User ISNULLOR p_Pwd ISNULLTHEN
error(57001); --用户名或密码不允许为空
ENDIF;
FOR i IN1 .. least(lengthb(v_Pwd), lengthb(v_User)) LOOP
v_Cmb := v_Cmb || substrb(v_User, i, 1) substrb(v_Pwd, i, 1);
ENDLOOP;
RETURN DBMS_OBFUSCATION_TOOLKIT.MD5(input_string => v_Cmb);
END;
--转自