Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var secret = SHIPFAST_HMAC_SECRET
- var hmac
- ...
- ...
- var obfuscatedSecretData = Buffer.from(secret, 'base64')
- var shipFastAPIKeyData = new Buffer("QXBwcm9vdidzIHRvdGFsbHkgYXdlc29tZSEh")
- for (var i = 0; i < Math.min(obfuscatedSecretData.length, shipFastAPIKeyData.length); i++) {
- obfuscatedSecretData[i] ^= shipFastAPIKeyData[i]
- }
- var obfuscatedSecret = new Buffer(obfuscatedSecretData).toString('base64')
- hmac = crypto.createHmac('sha256', Buffer.from(obfuscatedSecret, 'base64'))
- ...
- ...
- // Compute the request HMAC using the HMAC SHA-256 algorithm
- ...
- ...
- // Check to see if our HMAC matches the one sent in the request header
- // and send an error response if it doesn't
- if (ourShipFastHMAC != requestShipFastHMAC) {
- ...
Add Comment
Please, Sign In to add comment