#![allow(non_snake_case)]
mod algorithms;
mod argon2_impl;
mod errors;
pub use algorithms::PasswordHasherImpl;
pub use argon2_impl::Argon2Impl;
pub use errors::PasswordError;
pub struct PasswordHasher {
algorithm: Box<dyn PasswordHasherImpl>,
}
impl PasswordHasher {
pub fn new(algorithm: Box<dyn PasswordHasherImpl>) -> Self {
Self { algorithm }
}
pub fn hash_password(&self, password: &str) -> Result<String, PasswordError> {
self.algorithm.hash_password(password)
}
pub fn verify_password(&self, password: &str, hashed: &str) -> Result<bool, PasswordError> {
self.algorithm.verify_password(password, hashed)
}
}