node-rs
node-rs copied to clipboard
How to pass `salt` generated via `genSalt` to bcrypt `hash()`?
There are bcrypt functions exposed for generating salts (genSalt/genSaltSync), but it doesn't seem possible to pass their returned values to hash() as an alternative to the rounds parameter. I didn't see anything in the documentation or examples -- and it didn't seem possible in the source nor did there seem to be any tests that combined the functions. Did I just miss how to do it? Or is this an oversight / just not supported yet?
I checked the documentation and can't migrate because of this. Is this issue still valid?
The salt is automatically generated and included in the final hash when the hash function is called. Is there a specific reason why you need to provide the salt manually?
https://github.com/napi-rs/node-rs/blob/59fddf62f9c0eaa21443a540cbd6d900d0eb2672/packages/bcrypt/src/lib.rs#L80
However, looking at the bindings, it seems the hash functions can also handle externally provided salts.
https://github.com/napi-rs/node-rs/blob/main/packages/bcrypt/binding.d.ts