Mime encoded HMAC_SH256 in Oracle

Just going to say, mime encoding is almost as old as the Internet and is very used.

At work, we have a problem with vendor code. They are using java in Oracle. It works in TEST, but not in PROD. It is a permissions problem. I am no DBA right now.

What I enjoy about Oracle docs, is that there is amost no simple snippets of code to help or give ideas how to do things. AskTom is more the rule than the exception.

This is an example on doing an mime encoded hmac sha256 in oracle.

Pleasae note: dbms_crypt requires permissions.

select UTL_RAW.CAST_TO_VARCHAR2 (UTL_ENCODE.base64_encode(
dbms_crypto.mac(UTL_I18N.string_to_raw('MESSAGE', 'UTF8'),3,
utl_i18n.string_to_raw('KEY', 'UTF8')))) from dual;



The number 3 the same as: DBMS_CRYPTO.HMAC_SH256. Just that if you use DBMS_CRYPTO.HMAC_SH256 you get:

ORA-06553: PLS-221: 'HMAC_SH256' is not a procedure or is undefined
06553. 00000 -  "PLS-%s: %s"

The code above should work in Oracle 12c and above.


Comments powered by Disqus