Comparing BCrypt hash between PHP and NodeJS

后端 未结 3 1703
梦毁少年i
梦毁少年i 2020-12-04 15:04

For an app I\'m working on, nodejs needs to verify hashes created by PHP and vice-versa.

The problem is, the hashes generated in PHP (via Laravel\'s Hash

3条回答
  •  借酒劲吻你
    2020-12-04 15:21

    I have tried to compute what was said before to get codes that work. As you can see I don't need to replace anything.

    On the PHP 7.2.4 side:

    On the nodeJS side:

    Install bcryptjs package: npm i bcryptjs

    var bcrypt = require('bcryptjs');
    let hash1="$2y$10$5EaF4lMSCFWe7YqqxyBnR.QmDu1XhoiaQxrOFw.AJZkGCYmpsWDU6";
    console.log(bcrypt.compareSync("test123", hash1)); // display true
    

提交回复
热议问题