kelektiv / node.bcrypt.js

bcrypt for NodeJs
MIT License
7.43k stars 510 forks source link

Error: data must be a string or Buffer and salt must either be a salt string or a number of rounds #903

Closed LishuGupta652 closed 2 years ago

LishuGupta652 commented 2 years ago

It took me a while to figure out while this error was comming up. I tried to fix and searched a lot and finally came up with the solution that the salt created with bcrypt.gensalt(10) returned a string value but when i input the salt in bcrypt.hash(pass, salt) it required me to input the salf as integer

final solution should be using salt as a intenger bcrypt.hash(pass, parseInt(salt))

benbaker76 commented 2 years ago

Just use bcrypt.hash(pass, 10)

DamithaPerera commented 2 years ago

This works for me.

let pass= pass.toString(); bcrypt.hash(pass, 10);

saintgabriel0 commented 2 years ago

This also works.

let pass= pass.toString(); bcrypt.hash(pass, parseInt(salt));

LishuGupta652 commented 2 years ago

Thank you all this issue is now been resolved

iragena25egide commented 1 year ago

It took me a while to figure out while this error was comming up. I tried to fix and searched a lot and finally came up with the solution that the salt created with bcrypt.gensalt(10) returned a string value but when i input the salt in bcrypt.hash(pass, salt) it required me to input the salf as integer

final solution should be using salt as a intenger bcrypt.hash(pass, parseInt(salt))

thank you

piyushrai7271 commented 4 months ago

bcrypt.compair(password.toString(),this.password) // this work for me in compairing password while login user ... thanks everyone for help