Skip to content

Instantly share code, notes, and snippets.

@diorahman
Created May 20, 2016 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diorahman/a1762d2a56629615c7f014890f9064d2 to your computer and use it in GitHub Desktop.
Save diorahman/a1762d2a56629615c7f014890f9064d2 to your computer and use it in GitHub Desktop.
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