pub trait PasswordHasher: Send + Sync {
// Required methods
fn algorithm(&self) -> &'static str;
fn hash(&self, password: &str) -> Result<String, HasherError>;
fn verify(&self, password: &str, stored: &str) -> Result<bool, HasherError>;
fn identify(&self, stored: &str) -> bool;
}Expand description
One hasher’s algorithm-specific interface. The trait is sync — hashing is CPU-bound and current implementations don’t need an executor.
Required Methods§
Sourcefn algorithm(&self) -> &'static str
fn algorithm(&self) -> &'static str
Algorithm identifier ("argon2id", "bcrypt", …). Used in
telemetry and tests; not part of the wire format.
Sourcefn hash(&self, password: &str) -> Result<String, HasherError>
fn hash(&self, password: &str) -> Result<String, HasherError>
Produce a stored-hash string for password.
Sourcefn verify(&self, password: &str, stored: &str) -> Result<bool, HasherError>
fn verify(&self, password: &str, stored: &str) -> Result<bool, HasherError>
Constant-time verify against a stored hash that THIS hasher
produced. The chain calls this only after Self::identify
returns true, so implementations can assume the format is
theirs to parse.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl PasswordHasher for Argon2idHasher
Available on crate feature
passwords only.