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

Trailing underscores are not accounted for. #133

Open
savoygrizzly opened this issue Jun 16, 2022 · 1 comment
Open

Trailing underscores are not accounted for. #133

savoygrizzly opened this issue Jun 16, 2022 · 1 comment

Comments

@savoygrizzly
Copy link

When using bcrypt.compare(password, user.password) with the original hashed user.password being something and the supplied password being something__ or something_, bcrypt.compare will return true.

Just wondering if this is intended behavior, if it is I'd consider this VERY bad practice.

@dcodeIO
Copy link
Owner

dcodeIO commented Jun 16, 2022

The following works as expected and does not return true:

var hash = bcryptjs.hashSync("something");
var result = bcryptjs.compareSync("something_", hash);
console.log(result); // logs false

Note, though, that the maximum input length is 72 bytes as explained in the README, so if the input is longer than that, remaining bytes are truncated, which might explain the behavior.

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