因为现在输出的类似于这样:
s:FPyJtUyZ5357ikgs1EJqd7Tj.1tMYKBuQDfAGmaTq3MEbnO3Uf00OjeOHunh/KpVWbcU
能否修改下生成的格式,只输出字母以及数字,不要特殊字符
加密的包为:cookie-signature
地址:https://github.com/visionmedia/node-cookie-signature
加密:
exports.sign = function(val, secret){
if ('string' != typeof val) throw new TypeError('cookie required');
if ('string' != typeof secret) throw new TypeError('secret required');
return val + '.' + crypto
.createHmac('sha256', secret)
.update(val)
.digest('base64')
.replace(/\=+$/, '');
};
解密:
exports.unsign = function(val, secret){
if ('string' != typeof val) throw new TypeError('cookie required');
if ('string' != typeof secret) throw new TypeError('secret required');
var str = val.slice(0, val.lastIndexOf('.'));
return exports.sign(str, secret) == val ? str : false;
};
如果有什么问题修改下sign方法就可以了