Skip to content Skip to sidebar Skip to footer

How To Replicate Node's Crypto.createhmac( 'sha256', Buffer) In The Browser?

How to get to 'feature parity' between Node's Crypto.createHmac( 'sha256', buffer) and CryptoJS.HmacSHA256(..., secret)? I have a 3rd party code that does what you can see here as

Solution 1:

Change

atob(secret)

To

CryptoJS.enc.Base64.parse(secret)

Because if you pass a raw string as key to the function it will be re-parsed as UTF-8.

Post a Comment for "How To Replicate Node's Crypto.createhmac( 'sha256', Buffer) In The Browser?"