Skip to content

Commit

Permalink
Fix tj#15: use sha1 hashes for double signing
Browse files Browse the repository at this point in the history
  • Loading branch information
tenbits committed Jun 25, 2014
1 parent 1d1b25b commit f1465ee
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
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 f1465ee

Please sign in to comment.