MD5 encryption in Oracle

Source: Internet
Author: User

I. Technical Points
1. dbms_obfuscation_toolkit.md5
Dbms_obfuscation_toolkit.md5 is an MD5-encoded data packet function, but an error message is displayed when select dbms_obfuscation_toolkit.md5 (input_string => 'abc') A from dual, it seems that this function can only be called directly in the package and cannot be directly applied to select statements.
  
2. utl_raw.cast_to_raw
The string returned by dbms_obfuscation_toolkit.md5 is of the raw type. to display the string correctly, it must undergo utl_raw.cast_to_raw conversion.

 

II. Application

1. Direct call

Declare

V2 varchar2 (32 );

Begin

V2: = utl_raw.cast_to_raw (SYS. dbms_obfuscation_toolkit.md5 (input_string => '2016 '));

Dbms_output.put_line (V2 );

End;

Note: It can be called directly in the stored procedure. If you want to nest the MD5 call, remember to use utl_raw.cast_to_raw for conversion after each call. Otherwise, the final result is incorrect.

 

2. Call the constructor

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.