use*_*771 9 php passwords node.js
我面临的情况需要验证password_hash在nodejs服务器上通过PHP 方法创建的密码.
是否nodejs有可用的包相当于password_hash和password_verify?谢谢.
就我而言,我在php中创建了如下密码
$data['password'] = password_hash($data['password'],PASSWORD_BCRYPT);
Run Code Online (Sandbox Code Playgroud)
在节点中,如果我想验证密码比...
var bcrypt = require('bcrypt');
params.hash = params.hash.replace('$2y$', '$2a$');
bcrypt.compare(params.password, params.hash,async function(err, correct) {
console.log(correct);
});
Run Code Online (Sandbox Code Playgroud)
希望对您有帮助。