2016-02-02 06:04
浏览 77


Just to know about bcrypt hash comparison in different platforms, that I have one brypt hash which is generated at Nodejs server, now I am moving to PHP, I want to know about is this possible to compare already created bcrypt hashes(generated in Nodejs) in PHP

Node JS Code:

function hash(password) {
  return new Promise(function(fulfill, reject) {
    bcrypt.hash(password, 8, function(err, hashedPassword) {
      if (err) {
      } else {

Input : simha

output: $2a$10$c/EwGsRkoV4XHmsOJYWZ6.LurbDUFW.eq83SI8eu5JaMOsr6PyLrm

Is it possible to generate the ouput hash using input simha in PHP

I am trying the below one, but it is generating different hash

password_hash($password, PASSWORD_BCRYPT) 
//output : $2y$10$CfihL9RipXW88JAVvlyFlegM5BAyD5xQmNutjm9KepeXUn5cAwIX2

图片转代码服务由CSDN问答提供 功能建议

为了了解不同平台中的bcrypt哈希比较,我有一个在Nodejs服务器上生成的brypt哈希, 现在我转向PHP,我想知道这是否可以比较PHP中已经创建的bcrypt哈希(在Nodejs中生成)

节点JS代码: \ n

  function hash(password){
 return new Promise(function(fulfill,reject){
} else {
 <  p>输入: simha   

输出: $ 2a $ 10 $ c / EwGsRkoV4XHmsOJYWZ6.LurbDUFW.eq83SI8eu5JaMOsr6PyLrm n

是否可以使用PHP中的输入 simha 生成输出哈希


  password_hash($ password,PASSWORD_BCRYPT)
 //输出:$ 2y $ 10 $ CfihL9R  ipXW88JAVvlyFlegM5BAyD5xQmNutjm9KepeXUn5cAwIX2 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsgni26260 2016-02-02 06:20

    You shouldn't expect them to match, at least by default. This is because for both functions, a random salt is chosen every time you hash a value.

    The important thing is not that the hash outputs match, but that they still validate. So you could take the hashed output from node.js and use it with password_verify() in PHP for example, and it should validate.

    点赞 评论

相关推荐 更多相似问题