Skip to content

Instantly share code, notes, and snippets.

@TimHeckel
Last active July 17, 2017 20:02
Show Gist options
  • Save TimHeckel/ead3a62da4b75f5383f6b9e90efed9b7 to your computer and use it in GitHub Desktop.
Save TimHeckel/ead3a62da4b75f5383f6b9e90efed9b7 to your computer and use it in GitHub Desktop.
Broker Authentication
const CryptoJS = require("CryptoJS");
const _timestamp = new Date().toISOString();
const _sessionToken = "YOUR_SESSION_TOKEN_HERE";
const _secretKey = "YOUR_SECRET_KEY_HERE";
const _valToHash = _sessionToken + ":" + _timestamp;
const _hash = CryptoJS.HmacSHA256(_valToHash, _secretKey).toString(CryptoJS.enc.Base64);
const _authToken = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(_sessionToken + ":" + _hash));
return "SIF_HMACSHA256 " + _authToken;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment