Generate digest, with 2 Parameters + Algorithm?

I’m coordinating with an outside technology that needs me to pass some SHA256 digest hashed data: and my output must match their output.
However: they are passing two parameters to get their digest:

From their Ruby example:
hash = OpenSSL::HMAC.digest(‘sha256’, Data1, Data2)

How do I replicate this with 4D?

Note: I’ve realized that this is “HMAC” algorithm. I’m un-familiar with it.

Why not using the search engine of your choice?
I found this

key = 'key'
data = 'The quick brown fox jumps over the lazy dog'

hmac = OpenSSL::HMAC.digest('sha1', key, data)
#=> "\xDE|\x9B\x85\xB8\xB7\x8A\xA6\xBC\x8Az6\xF7\n\x90p\x1C\x9D\xB4\xD9"

Source: https://ruby-doc.org/stdlib-2.4.0/libdoc/openssl/rdoc/OpenSSL/HMAC.html

Unfortunately 4D doesn’t support HMAC natively. But Bruno Legay implemented this in his jwt component.
Look here: https://github.com/blegay/jwt_component

Maybe @LEGAY.Bruno knows something more about it.
HTH
Lutz

Thanks for the reply.
I’ve realized that I can also use NTK (which I already have in this project) to do HMAC authentication.

1 Like

Hi Lutz,

Yes, in the jwt_component (https://github.com/blegay/jwt_component/) there is a 4D native SHA2 256 HMAC.

1 Like