Skip to content

Instantly share code, notes, and snippets.

@smebberson
Created March 8, 2017 22:02
Show Gist options
  • Save smebberson/baf0556940a29cfd3ac14364f30cbe58 to your computer and use it in GitHub Desktop.
Save smebberson/baf0556940a29cfd3ac14364f30cbe58 to your computer and use it in GitHub Desktop.
x-key header
/**
* Helper function to create an api key
* @param {String} data The string to encrypt
* @return {String} The sha256 hash result
*/
function createHmac (data) {
const crypto = require('crypto');
const hmac = crypto.createHmac('sha256', config.get('appSecret'));
hmac.update(data);
return hmac.digest('hex');
}
const data = createHmac(config.get('appId'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment