Looks like you pad the key, append the msg, then hash.  Then pad the key again, 
append the previous hash, and hash again.

https://stackoverflow.com/questions/11415055/how-to-use-hmac-sha256

From: Two Way Communications <rudy.mort...@twowaycommunications.be>
Date: Friday, March 20, 2020 at 9:37 AM
To: Spencer Hinsdale <spen...@bigsoftware.com>
Cc: 4D iNug Technical <4d_tech@lists.4d.com>
Subject: Re: HMAC SHA256 in native 4D code?

Hi Spencer,

I have been looking at it, but it does not do what I want to do.

I need to construct a JSON Web Token (JWT)

For that, I need to encrypt a string with a secret key, to obtain the encrypted 
token.
As far as I can see there is no parameter in ‘Generate Digest' to do so.

I tried to use:

PHP 
Execute(“";"hash_hmac";$HMACSHA256;"sha256";($base64UrlHeader+"."+$base64UrlPayload);$key)

but the signature that is being returned does not work with JWT.

I tested it on jwt.io<http://jwt.io>, and it returns ‘invalid’.

So I am looking for other ways to generate this HMAC SHA256


Regards,
Rudy Mortier
Two Way Communications bvba




On 20 Mar 2020, at 17:18, Spencer Hinsdale 
<spen...@bigsoftware.com<mailto:spen...@bigsoftware.com>> wrote:

Does this help?

https://doc.4d.com/4Dv17/4D/17.4/Generate-digest.301-4882385.en.html


On 3/20/20, 9:15 AM, "4D_Tech on behalf of Rudy Mortier via 4D_Tech" 
<4d_tech-boun...@lists.4d.com on behalf of 4d_tech@lists.4d.com> wrote:

   Hi Bruno,

   I was looking in nabble to find a solution for generating HMAC-SHA256 keys.


**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to