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

Document the upper and lower bounds for the rounds parameter in genSaltSync #898

Open
nomuna opened this issue Nov 5, 2021 · 0 comments
Labels

Comments

@nomuna
Copy link

nomuna commented Nov 5, 2021

Apparently the rounds parameter for the method bcrypt.genSaltSync() has an upper bound of 31.
According to the encode_salt in bcrypt.cc.

/**
 * @param rounds The cost of processing the data. Default 10.
 * @param minor The minor version of bcrypt to use. Either 'a' or 'b'. Default 'b'.
 *
 * @example
 * import * as bcrypt from 'bcrypt';
 * const saltRounds = 10;
 *
 * const salt = bcrypt.genSaltSync(saltRounds);
 */
export declare function genSaltSync(rounds?: number, minor?: "a" | "b"): string;

For higher numbers a cryptic error message is created which misleads people to thinking that they may have passed in an argument of wrong type or format.

Error: Invalid salt. Salt must be in the form of: $Vers$log2(NumRounds)$saltvalue
@recrsn recrsn added the bug label Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants