PasswordHasher

Trait PasswordHasher 

Source
pub trait PasswordHasher<H> {
    // Required method
    fn hash_password_with_salt(
        &self,
        password: &[u8],
        salt: &[u8],
    ) -> Result<H, Error>;

    // Provided methods
    fn hash_password(&self, password: &[u8]) -> Result<H, Error> { ... }
    fn hash_password_with_rng<R>(
        &self,
        rng: &mut R,
        password: &[u8],
    ) -> Result<H, Error>
       where R: TryCryptoRng + ?Sized { ... }
}
Available on crate feature password-hash only.
Expand description

High-level trait for password hashing functions.

Generic around a password hash to be returned (typically [phc::PasswordHash])

Required Methods§

Source

fn hash_password_with_salt( &self, password: &[u8], salt: &[u8], ) -> Result<H, Error>

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.

Provided Methods§

Source

fn hash_password(&self, password: &[u8]) -> Result<H, Error>

Available on crate feature getrandom only.

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.

Source

fn hash_password_with_rng<R>( &self, rng: &mut R, password: &[u8], ) -> Result<H, Error>
where R: TryCryptoRng + ?Sized,

Available on crate feature rand_core only.

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 from the provided RNG.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§