DEFINE VARIABLE chJSONData AS CHARACTER NO-UNDO.
DEFINE VARIABLE chKey AS CHARACTER NO-UNDO.
DEFINE VARIABLE lcLong AS LONGCHAR NO-UNDO.
chJSONData = '{data:"somedatahere"}'.
chKey = "ApplicationKey" .
lcLong = HEX-ENCODE(MESSAGE-DIGEST("HMAC-SHA-256" , chJSONData, chKey)).
MESSAGE STRING(chLong).
/* correction by Valery A.Eliseev */
IF LENGTH(pcKey) > {&xiBlockSize} THEN
DO:
set-size(mData) = LENGTH(pcKey).
put-string(mData, 1, LENGTH(pcKey)) = pcKey.
// Only valid for HMAC-SHA-1
// rRawDataSHA = SHA1-DIGEST(mData).
rRawDataSHA = MESSAGE-DIGEST('SHA-256', mData).
PUT-BYTES(mKey, 1) = rRawDataSHA.
END.
I'm glad you did that, very useful !I wrote this function for a particular purpose over 15 years ago . I’m still amazed today that it’s being used.
Customer is using AIX, so no .Net here. They will migrate to OE 11.7 (and then to 12) in a couple months, so this code will be replaced with the builtin version.Is it possible that you could use an alternative method like .net?
Before I wrote the function many many years ago, i used a command line utility to do the hashing, maybe something like that still exist today as alternative workaround?