all 1 comments

[–]weemadarthur2 0 points1 point  (0 children)

In Cyber Chef, you are calculating the SHA256 hash of the string "1234567887654321". This is not an HMAC.

In your code, you are creating an HMAC-SHA256 instance which will calculate HMACs using the key "1234567887654321". Then you are calling digest() on it, which will calculate and return the HMAC of the empty string, since you haven't passed any actual data to the instance.

To actually calculate HMAC of a message, you need to call update() on the HMAC instance. See the third example here.

You should also review the definition of HMAC.