Skip to content

Commit

Permalink
Merge pull request #17 from tenbits/patch-1
Browse files Browse the repository at this point in the history
Fix #15: use sha1 hashes for double signing
  • Loading branch information
natevw committed Jun 25, 2014
2 parents 1d1b25b + 0aa4ec2 commit 4cc5e21
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion index.js
Expand Up @@ -39,5 +39,13 @@ exports.unsign = function(val, secret){
var str = val.slice(0, val.lastIndexOf('.'))
, mac = exports.sign(str, secret);

return exports.sign(mac, secret) == exports.sign(val, secret) ? str : false;
return sha1(mac) == sha1(val) ? str : false;
};

/**
* Private
*/

function sha1(str){
return crypto.createHash('sha1').update(str).digest('hex');
}

0 comments on commit 4cc5e21

Please sign in to comment.