由于某种原因,该bcrypt.hash方法挂起并且从不调用其回调.
bcrypt.genSalt(29, function(err, salt) {
if (err) {
res.json({ success: false, msg: err.message });
} else {
bcrypt.hash(req.body.password, salt, function (err, hash) {
// This function is never called
res.json({ success: true });
});
}
});
Run Code Online (Sandbox Code Playgroud)
有什么建议?
UPDATE
它似乎与express.js等无关.我刚刚创建了一个脚本文件test.js:
var bcrypt = require('bcrypt');
var pwd = 'Test password 123';
bcrypt.genSalt(29, function(err, salt) {
if (err) {
console.log('1: ' + err.message);
} else {
console.log('Salt: ' + salt);
bcrypt.hash(pwd, salt, function (err, hash) {
if (err) {
console.log('2: ' + err.message);
} else {
console.log('Hash: ' + hash);
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
然后我通过使用来启动它node test.js.它输出一个salt,之后它会挂起并且bcrypt.hash在任何情况下都不会调用它的回调函数.我正在使用OS X,我安装了节点v7.8.0.
29轮盐轮意味着Math.pow(2, 29)关键的扩张轮次,这需要很长时间.
为了显示:
您可以通过数学来计算使用29轮所需的时间(它在260万秒或大约一个月的某个时间点).
| 归档时间: |
|
| 查看次数: |
873 次 |
| 最近记录: |