Skip to content

Instantly share code, notes, and snippets.

@nolim1t
Last active June 15, 2023 21:35
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nolim1t/e260aaddfe9b6d3cb6ab to your computer and use it in GitHub Desktop.
Save nolim1t/e260aaddfe9b6d3cb6ab to your computer and use it in GitHub Desktop.
node.js HMAC SHA512 signing
var crypto = require("crypto");
function encrypt(key, str) {
var hmac = crypto.createHmac("sha512", key);
var signed = hmac.update(new Buffer(str, 'utf-8')).digest("base64");
return signed
}
@nolim1t
Copy link
Author

nolim1t commented Aug 6, 2015

Example code

console.log(encrypt("test", "hello world"));
console.log(encrypt("test", "goodbye world"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment