pub trait PasswordHasher<H> {
// Required method
fn hash_password_with_salt(&self, password: &[u8], salt: &[u8]) -> Result<H>;
// Provided method
fn hash_password(&self, password: &[u8]) -> Result<H> { ... }
}Expand description
High-level trait for password hashing functions.
Generic around a password hash to be returned (typically phc::PasswordHash)
Required Methods§
Sourcefn hash_password_with_salt(&self, password: &[u8], salt: &[u8]) -> Result<H>
fn hash_password_with_salt(&self, password: &[u8], salt: &[u8]) -> Result<H>
Compute the hash H from the given password and salt, potentially using configuration
stored in &self for the parameters, or otherwise the recommended defaults.
The salt should be unique per password. When in doubt, use PasswordHasher::hash_password
which will choose the salt for you.
§Errors
These will vary by algorithm/implementation of this trait, but may be due to:
- length restrictions on the password and/or salt
- algorithm-specific internal error
Provided Methods§
Sourcefn hash_password(&self, password: &[u8]) -> Result<H>
fn hash_password(&self, password: &[u8]) -> Result<H>
Compute the hash H from the given password, potentially using configuration stored in
&self for the parameters, or otherwise the recommended defaults.
A large random salt will be generated automatically.
§Errors
These will vary by algorithm/implementation of this trait, but may be due to:
- length restrictions on the password
- algorithm-specific internal error
- RNG internal error