Iamlaosong
Because of the use of MD5 encryption, so on the Internet to search the relevant information, and conduct a careful study. The core is the MD5 encoded packet function:dbms_obfuscation_toolkit. MD5, where the raw type is concerned, is actually the original code value.
The result of MD5 encryption is a 16 byte value, which is is the Raw type, is not displayed, to correctly display, need to undergo utl_raw.cast_to_raw conversion, the function is to each byte of the ASCII value is expressed in characters. To illustrate this, consider the following: Assuming that the binary value of a byte is 0100 0001, the hexadecimal representation is 41, and the value is actually the ASCII code value of the letter "A", then it becomes the string "41" after the Utl_raw.cast_to_raw conversion.
The Utl_raw.cast_to_raw function can also convert a string, that is, the code value of the string (which should be an Oracle character set) in hexadecimal notation, for example:
The result of Utl_raw.cast_to_raw (' Iamlaosong ') is: 69616d6c616f736f6e67
The result of Utl_raw.cast_to_raw (' I'm Lao Song ') is: CED2CAC7C0CFCBCE
The MD5 package functions are used as follows:
1 , call directly
Declare
V2 VARCHAR2 (32);
Begin
V2: = Utl_raw.cast_to_raw (sys.dbms_obfuscation_toolkit.md5 (input_string = ' 123456 '));
Dbms_output.put_line (v2);
End
displaying results: e10adc3949ba59abbe56e057f20f883e
This string is actually the result of a 16-byte value in hexadecimal, where the characters are 0-9 and A-f, and because of this, the letter case is irrelevant, all representing the same value.
For example, the string: Iamlaosong, the result of the encrypted display: 7e0fb497d8c4515157ddeafc2e511290, apparently, is also a hexadecimal representation of 16 bytes.
As for the comparison of encryption results, it is more intuitive to convert to string, and it is easier to compare them.
2 , constructor, and then call the
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;
Example of calling the MD5 function:
Select MD5 (1) from dual
MD5 Encryption in Oracle