9

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;
DOK
  • 32,337
  • 7
  • 60
  • 92
Bob Kuhar
  • 10,838
  • 11
  • 62
  • 115
  • See also http://stackoverflow.com/q/1749753/272735 The answer is basically the same even the hash algorithms are different (MD5 vs. SHA1). – user272735 Jan 12 '15 at 13:03

4 Answers4

12

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
Jon Heller
  • 34,999
  • 6
  • 74
  • 132
12

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.
Eddie Awad
  • 3,669
  • 1
  • 19
  • 17
  • `DBMS_OBFUSCATION_TOOLKIT` is deprecated at least since 11g R2. Use `DBMS_CRYPTO` instead. (Or `STANDARD_HASH` in 12c.) – user272735 Jan 12 '15 at 12:59
8

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

Matt
  • 74,352
  • 26
  • 153
  • 180
René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293
  • Thanks for the link...now I need to pitch this to some DBA to get it available to me. Oh well...at least it exists, just not OOB functionality. Thanks – Bob Kuhar Jan 11 '12 at 22:10
-4

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

ligerdave
  • 714
  • 2
  • 6
  • 13