Is there an MD5 Sum function in PL/SQL

36.7k views Asked by At

In Oracle SQL, is there an MD5 function or something available to me? I would like to do something like...

select name, md5_sum( name ) from person;
4

There are 4 answers

1
René Nyffenegger On BEST ANSWER

See this Tahiti Link. Under MD5 Procedures and Functions it says These subprograms generate MD5 hashes of data. The MD5 algorithm ensures data integrity by generating a 128-bit cryptographic message digest value from given data.

Also note, that DBMS_OBFUSCATION_TOOLKIT is deprecated and can/should be replaced with DBMS_CRYPTO, see this Tahiti Link

0
ligerdave On

don't think it comes with it right out of box. you need to define your own.

1
Eddie Awad On

You may want to check the DBMS_OBFUSCATION_TOOLKIT.MD5 procedure.

Here is an example:

     SQL> column md5_val FORMAT A40
     SQL> SELECT DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw('Eddie')) md5_val
       2    FROM DUAL;
     MD5_VAL
     ----------------------------------------
     E5F6C83E6E97C74FC9E9760FC8972AED

     1 row selected.
0
Jon Heller On

In 12c you can use STANDARD_HASH. It's available by default, does not require any PL/SQL objects or hard-coded values, and is not deprecated.

SQL> select standard_hash('Finally, an easy way to do this.', 'MD5') md5
  2  from dual;

MD5
--------------------------------
456E4D024B4BB704169E21DEB895B0E2