Skip to content

Instantly share code, notes, and snippets.

@mattrobenolt
Forked from anonymous/gist:1338244
Created November 3, 2011 23:46
Show Gist options
  • Save mattrobenolt/1338289 to your computer and use it in GitHub Desktop.
Save mattrobenolt/1338289 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);
var new_signature = hmac.digest('hex');
console.log(new_signature);
return signature === new_signature;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment