As part of shopify’s web hook, they pass a validation key.
Basically, it’s this:
- convert the API key to to UTF8 bytes (keyBytes = UTF8Bytes(apiKey))
- create an HMACSHA256 hash of the body of the request and the converted api key (hmacBytes=HashHmacSha256(“some string”, keyBytes))
- convert the above result to base64 (validationKey=BytesToBase64(hmacBytes))
I’m trying to emulate this in liquid using :
“some string”| hmac_sha256:“my api key”| base64_encode
but “my api key” needs to get converted to UTF8Bytes
Is this possible? Of course, it’s doable in javascript but that exposes the API key.
The whole issue boils down to the liquid hmac256 implementation. It returns nothing like what javascript returns which is what every site I’ve tested returns – a 44-byte string. I don’t know what shopify has done, but this is not hmac sha256.
Thank you