Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compare always returns success #51

Closed
EvaldasVasiliauskas opened this issue Jan 8, 2017 · 2 comments
Closed

compare always returns success #51

EvaldasVasiliauskas opened this issue Jan 8, 2017 · 2 comments

Comments

@EvaldasVasiliauskas
Copy link

EvaldasVasiliauskas commented Jan 8, 2017

no matter what password I pass, compare always returns success. Am I doing something wrong?
Here's an example of very primitive app:

var bcrypt = require('bcryptjs');

var mypass = 'B4c0/\/';
var mysalt = '';
var myhash = '';

mysalt = bcrypt.genSaltSync(10);
myhash = bcrypt.hashSync(mypass, mysalt);

bcrypt.compare(mypass + 'a', myhash)
.then(() => {console.log("Comparison was true")})
.catch(() => {console.log("Comparison was false")});

OS: Win x64
npm: 4.0.5
node: 7.4.0

@dcodeIO
Copy link
Owner

dcodeIO commented Jan 8, 2017

I'd say the README example on promises (pr) is incorrect:

bcrypt.compare(mypass + 'a', myhash)
.then((res) => {console.log("Comparison was: " + res)})
.catch(() => {console.log("Exception thrown")});

@EvaldasVasiliauskas
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants