Skip to main content

crypto_pwhash_str

Function crypto_pwhash_str 

Source
pub fn crypto_pwhash_str(
    password: &[u8],
    opslimit: u64,
    memlimit: usize,
) -> Result<String, Error>
Available on crate feature base64 only.
Expand description

Hash a password string with a random salt.

This function provides a wrapper for crypto_pwhash that returns a string encoding of a hashed password with a random salt, suitable for use with password hash storage (i.e., in a database). Can be used to verify a password using crypto_pwhash_str_verify.

Compatible with libsodium’s crypto_pwhash_str.

§Errors

Returns an error if the password or resource limits are unsupported, or if Argon2 cannot hash the password.

§Panics

Panics if the operating system’s random number generator fails.