Skip to content

Instantly share code, notes, and snippets.

Created November 3, 2011 23:22
Show Gist options
  • Save anonymous/1338244 to your computer and use it in GitHub Desktop.
Save anonymous/1338244 to your computer and use it in GitHub Desktop.
var secret_key = 'abcdefghijklmnopqrstuvwxyz';
var hash = crypto.createHash('sha1');
hash.update(secret_key);
console.log(unsign_value('8a8d431c4bee603699e3fd3e9593a3264af0f57c', 'value1'));
function unsign_value(signature, value)
{
var hmac = crypto.createHmac('sha1', hash.digest());
hmac.update(value);
console.log(signature);
console.log(hmac.digest('hex'));
return signature === hmac.digest('hex');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment