Last active
July 17, 2017 20:02
-
-
Save TimHeckel/ead3a62da4b75f5383f6b9e90efed9b7 to your computer and use it in GitHub Desktop.
Broker Authentication
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
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