pub trait PasswordHashFunction: KeyDerivationFunction + ParamProvider {
type Password: AsRef<[u8]> + AsMut<[u8]> + Clone + Zeroize;
// Required methods
fn hash_password(&self, password: &Self::Password) -> Result<PasswordHash>;
fn verify(
&self,
password: &Self::Password,
hash: &PasswordHash,
) -> Result<bool>;
fn benchmark(&self) -> Duration;
fn recommended_params(target_duration: Duration) -> Self::Params;
}
Expand description
Trait for password hashing functions with type-level guarantees
Required Associated Types§
Required Methods§
Sourcefn hash_password(&self, password: &Self::Password) -> Result<PasswordHash>
fn hash_password(&self, password: &Self::Password) -> Result<PasswordHash>
Hashes a password with the configured parameters
Sourcefn verify(&self, password: &Self::Password, hash: &PasswordHash) -> Result<bool>
fn verify(&self, password: &Self::Password, hash: &PasswordHash) -> Result<bool>
Verifies a password against a hash
Sourcefn recommended_params(target_duration: Duration) -> Self::Params
fn recommended_params(target_duration: Duration) -> Self::Params
Recommends parameters based on a target duration
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.