Skip to main content

hash

Function hash 

Source
pub fn hash<P: AsRef<[u8]>>(password: P, cost: u32) -> BcryptResult<String>
Expand description

Hash a password with a fresh random salt, returning the 60-byte $2b$ hash string.

The salt comes from the OS CSPRNG (hence std). Like every single-hash function here, this never touches the SIMD backends: one bcrypt hash is strictly sequential, so it always runs the scalar kernel.

ยงErrors

CostNotAllowed if cost is outside 4..=31; Rand if the OS entropy source fails.