Skip to main content

PasswordHasher

Trait PasswordHasher 

Source
pub trait PasswordHasher: Send + Sync {
    // Required methods
    fn hash(&self, plain: &str) -> Result<String, SecurityError>;
    fn verify(&self, hashed: &str, plain: &str) -> Result<bool, SecurityError>;
}
Expand description

Hashes and verifies password strings.

Required Methods§

Source

fn hash(&self, plain: &str) -> Result<String, SecurityError>

Returns a PHC-formatted hash for plain.

§Errors

Returns SecurityError::Password when hashing fails or plain is empty.

Source

fn verify(&self, hashed: &str, plain: &str) -> Result<bool, SecurityError>

Returns true when plain matches hashed.

§Errors

Returns SecurityError::Password when hashed is not a valid PHC string.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§