First, technical points
1, Dbms_obfuscation_toolkit. MD5
Dbms_obfuscation_toolkit. MD5 is a MD5 encoded packet function, but I am using select Dbms_obfuscation_toolkit. MD5 (input_string => ' abc ') A from dual, it appears that the function can only be invoked directly in the package and cannot be applied directly to the SELECT statement.
2, Utl_raw.cast_to_raw
Dbms_obfuscation_toolkit. MD5 returns the string, is the Raw type, to be properly displayed, requires a utl_raw.cast_to_raw conversion
Second, the application
1. Direct call
Copy Code code as follows:
Declare
V2 VARCHAR2 (32); Begin
V2: = Utl_raw.cast_to_raw (sys.dbms_obfuscation_toolkit.md5 (input_string => ' 111 '));
Dbms_output.put_line (v2); End
Note: You can call directly in the stored procedure, if you want to nest call MD5, remember to use Utl_raw.cast_to_raw after each call, or the final result is wrong.
2, after the constructor, and then call
Copy Code code as follows:
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;
Call the MD5 function example:
Copy Code code as follows:
Additional: Oracle MD5 Function statement
Copy Code code as follows:
MD5 function statements in--oracle
Create or replace FUNCTION "Md5hash" (str in VARCHAR2)
Return VARCHAR2
Is V_checksum VARCHAR2 (32);
BEGIN
V_checksum: = LOWER (Rawtohex (Utl_raw. Cast_to_raw (SYS.DBMS_OBFUSCATION_TOOLKIT.MD5 (input_string => str)));
return v_checksum;
EXCEPTION
When No_data_found THEN
NULL;
When others THEN
--Consider logging the error and then re-raise raise;
End Md5hash;