【发布时间】:2015-10-17 09:48:27
【问题描述】:
我已经尝试过多次使用 node.js crypto 包来计算 req.body SHA1 值。但总有不一样的。
我正在使用以下代码:
var body = req.body;
var sig = 'sha1=' + crypto.createHmac('sha1', secret).update(JSON.stringify(body)).digest('hex');
console.log(sig === req.headers['x-hub-signature']) // not equal :(
或
var body = req.body;
var sig = 'sha1=' + crypto.createHmac('sha1', secret).update(new Buffer(JSON.stringify(body))).digest('hex');
console.log(sig === req.headers['x-hub-signature']) //not equal :(
如果您能给我任何帮助,我将不胜感激!
谢谢:)
【问题讨论】: