Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

password_hash equivalent in nodejs

I'm facing a situation that need to verify password created via PHP password_hash method on nodejs server.

Does nodejs have an available package that equivalent to password_hash and password_verify? Thank you.

like image 943
user3828771 Avatar asked Jul 20 '14 15:07

user3828771


2 Answers

In my case i created password in php like below

$data['password'] = password_hash($data['password'],PASSWORD_BCRYPT);

In Node if i want to verify that password than ...

var bcrypt = require('bcrypt');
params.hash = params.hash.replace('$2y$', '$2a$');
bcrypt.compare(params.password, params.hash,async function(err, correct) {
 console.log(correct);
});

Hope it will help you .....

like image 144
Renish Gotecha Avatar answered Sep 25 '22 06:09

Renish Gotecha


No, you will have to make use of one of the many Bcrypt libraries for Node.js.

P.S.: You're basically duplicating another user's question (Verify password hash in nodejs which was generated in php).

like image 32
chrisp Avatar answered Sep 24 '22 06:09

chrisp