Is there an MD5 Sum function in PL/SQL
Asked Answered
S

4

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;
Shrewish answered 11/1, 2012 at 21:50 Comment(1)
See also https://mcmap.net/q/690243/-making-a-sha1-hash-of-a-row-in-oracle/272735 The answer is basically the same even the hash algorithms are different (MD5 vs. SHA1).Amadoamador
G
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

Grani answered 11/1, 2012 at 21:56 Comment(1)
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. ThanksShrewish
C
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.
Cence answered 11/1, 2012 at 21:58 Comment(1)
DBMS_OBFUSCATION_TOOLKIT is deprecated at least since 11g R2. Use DBMS_CRYPTO instead. (Or STANDARD_HASH in 12c.)Amadoamador
P
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
Plauen answered 13/8, 2013 at 4:34 Comment(0)
G
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

Grani answered 11/1, 2012 at 21:56 Comment(1)
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. ThanksShrewish
H
-4

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

Humble answered 11/1, 2012 at 21:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.