Created
May 20, 2016 00:07
-
-
Save diorahman/a1762d2a56629615c7f014890f9064d2 to your computer and use it in GitHub Desktop.
This file contains 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
import crypto from 'crypto'; | |
/** | |
* @param {String} secret | |
* @param {String} href | |
* @param {Object} payload | |
*/ | |
export default (secret, href, payload) => { | |
payload = JSON.stringify(payload); | |
calculated = crypto | |
.createHmac('sha1', secret) | |
.update(payload) | |
.update(href) | |
.digest('base64'); | |
return calculated; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment