Noticed this when I was reading the salt rounds value from an environment variable, which is returned as a string.
bcrypt.hashSync(str, '10') throws the error "Error: Invalid salt. Salt must be in the form of: $Vers$log2(NumRounds)$saltvalue"
bcrypt.genSaltSync('10') throws the error "Error: rounds must be a number"
I believe the error for genSaltSync should probably be the error thrown in hashSync for the same input of a string value for the rounds.
Using node 6.3.0.
Nah. The error your seeing in hashSync is because you need to supply the salt, not the rounds.
However, we should probably allow genSaltSync to accept a string and just check if the value is NaN, then throw/return an error. Alternatively, you could just parseInt() the env variable.
Most helpful comment
Nah. The error your seeing in hashSync is because you need to supply the salt, not the rounds.
However, we should probably allow
genSaltSyncto accept a string and just check if the value is NaN, then throw/return an error. Alternatively, you could justparseInt()the env variable.