Last active
October 10, 2015 17:02
-
-
Save joshbeckman/2c528833860b5d1e5c34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var crypto = require('crypto'), | |
secret = 'OUR_APP_SHARED_SECRET', | |
message = req.rawBody.toString('utf8'), | |
digest = crypto.createHmac('SHA256', secret) | |
.update(new Buffer(message, 'utf8')) | |
.digest('base64'); | |
console.log(digest == req.headers['X-Shopify-Hmac-Sha256']); | |
// true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Technically, line #5 doesn't need to be a
Buffer
forcrypto
to hash your message, but it is required when•
unicode characters are in thereq.body
payload. Otherwise, the digest will not match the provided hmac hash from Shopify.