Skip to content

Instantly share code, notes, and snippets.

@yippeykeiyay
Last active May 25, 2021 16:25
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 yippeykeiyay/8511c06636f59024004250a0e3128ed1 to your computer and use it in GitHub Desktop.
Save yippeykeiyay/8511c06636f59024004250a0e3128ed1 to your computer and use it in GitHub Desktop.
Postman public & private key hash
/**
* Place this in your Pre-request Script section of your Postman calls to the RapidSpike API.
*
* Then add this query string to your request URLs: `?public_key={{publicKey}}&time={{unixTime}}&signature={{signature}}`
*/
var publicKey = 'put-your-public-key';
var privateKey = 'put-your-private-key-here';
var unixTime = Math.floor(Date.now() / 1000);
var pack = publicKey + "\n" + unixTime;
var hash = CryptoJS.HmacSHA1(pack, privateKey);
var signature = encodeURIComponent(hash.toString(CryptoJS.enc.Base64));
// Place the required variables into the environment to use in the query string (see above)
pm.environment.set("publicKey", publicKey);
pm.environment.set("unixTime", unixTime);
pm.environment.set("signature", signature);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment