Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js bcrypt.hash不调用其回调_Node.js_Bcrypt - Fatal编程技术网

Node.js bcrypt.hash不调用其回调

Node.js bcrypt.hash不调用其回调,node.js,bcrypt,Node.js,Bcrypt,由于某种原因,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 funct

由于某种原因,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 });
        });
    }
});
有什么建议吗

更新

它似乎与express.js等无关。 我刚刚创建了一个脚本文件test.js:

然后我使用node test.js启动它。它输出一个salt,然后挂起,bcrypt.hash在任何情况下都不会调用其回调函数,无论是否有错误。我正在使用OS X,并且已经安装了node v7.8.0。

29个salt rounds意味着Math.pow2,29个键扩展回合,这需要很多时间

举例说明:

10发子弹在我的MBP上大约需要78毫秒 12发子弹大约需要300毫秒 14发子弹大约需要1170毫秒 16发子弹大约需要4700毫秒 你也许可以计算出使用29轮需要多长时间,大约是260万秒,或者大约一个月。

29轮盐弹意味着数学。pow2,29轮关键扩展轮,需要时间

举例说明:

10发子弹在我的MBP上大约需要78毫秒 12发子弹大约需要300毫秒 14发子弹大约需要1170毫秒 16发子弹大约需要4700毫秒
你可以计算出使用29轮所需的时间,大约是260万秒,或者大约一个月。

第一次回调是否抛出错误?此外,是否定义了req.body.password?我假设它位于某个端点内部,但没有看到相应的代码。@user2263572 1。二号。Yes@user2263572我做了一个更新是第一次回调抛出错误吗?此外,是否定义了req.body.password?我假设它位于某个端点内部,但没有看到相应的代码。@user2263572 1。二号。Yes@user2263572我已经做了一个更新,因为我确信29-是一个盐串的长度。现在看来我开始明白了。谢谢非常感谢-我不知道子弹有那么贵!Geesh出于某种原因,我确信29-是一根盐绳的长度。现在看来我开始明白了。谢谢非常感谢-我不知道子弹有那么贵!怪人
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);
            }
        });
    }
});