Skip to main content

PasswordHash

Trait PasswordHash 

Source
pub trait PasswordHash {
    type Params;

    const ALGORITHM: &'static str;

    // Required methods
    fn hash_password(password: &[u8], params: &Self::Params) -> Result<String>;
    fn verify_password(password: &[u8], hash: &str) -> Result<bool>;
    fn derive_key(
        password: &[u8],
        salt: &[u8],
        params: &Self::Params,
        output_len: usize,
    ) -> Result<Vec<u8>>;
}
Expand description

Trait for password-based key derivation.

Required Associated Constants§

Source

const ALGORITHM: &'static str

Algorithm name.

Required Associated Types§

Source

type Params

Parameters type.

Required Methods§

Source

fn hash_password(password: &[u8], params: &Self::Params) -> Result<String>

Hash a password for storage.

Returns a string suitable for storage (includes salt and parameters).

Source

fn verify_password(password: &[u8], hash: &str) -> Result<bool>

Verify a password against a stored hash.

Source

fn derive_key( password: &[u8], salt: &[u8], params: &Self::Params, output_len: usize, ) -> Result<Vec<u8>>

Derive key material from password.

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§