shaneMangudi / bcrypt-nodejs

Native implementation of bcrypt for NodeJS
Other
574 stars 69 forks source link

bcrypt compare always return fall #36

Closed rickdana closed 9 years ago

rickdana commented 9 years ago

Hello, I'm implementing an user auth with Bcrypt. I'm facing an issue when comparing the given password with the one store in my DB i always have a false message. here is my compare method :

bcrypt.compare(param.motdepasse , client.motdepasse, function(err, pass) { if(err) res.json(200,{Message :'Error'}); if(pass == true){ client.isAuthenticate = 'true'; res.json(client); }else{ res.json(200,{Message :'Mot de passe érronée !'}); }

  });

Please any idea? thk!

prabodh1194 commented 9 years ago

I faced this issue once. Check the lengths of the generated hash and the one you address storing. E.g. The generated hash from bcrypt is 60 letters but you are storing only 50(say), then comparison issues will come.

rickdana commented 9 years ago

thank u i got it solve. the problem was the length of my password in my db

prabodh1194 commented 9 years ago

Length Alert :)