pub struct PasswordHasher { /* private fields */ }Expand description
Hashes passwords with Argon2id and checks them, with a dummy hash for names nobody keeps.
use coqui_access_kit::{Argon2Params, PasswordHasher};
let hasher = PasswordHasher::new(Argon2Params::new(64, 1, 1).unwrap()).unwrap();
let stored = hasher.hash("correct horse").unwrap();
assert!(hasher.verify(Some(&stored), "correct horse"));
assert!(!hasher.verify(Some(&stored), "wrong"));
// No such account: the same work is done, and the answer is no.
assert!(!hasher.verify(None, "correct horse"));Implementations§
Source§impl PasswordHasher
impl PasswordHasher
Sourcepub fn new(params: Argon2Params) -> Result<Self, String>
pub fn new(params: Argon2Params) -> Result<Self, String>
Sourcepub fn max_password_bytes(self, most: Limit) -> Self
pub fn max_password_bytes(self, most: Limit) -> Self
This hasher refusing to hash, and never matching, a password longer than most bytes.
Default DEFAULT_MAX_PASSWORD_BYTES.
Sourcepub fn params(&self) -> Argon2Params
pub fn params(&self) -> Argon2Params
The costs new hashes are made with.
Trait Implementations§
Source§impl Clone for PasswordHasher
impl Clone for PasswordHasher
Source§impl Debug for PasswordHasher
impl Debug for PasswordHasher
Auto Trait Implementations§
impl Freeze for PasswordHasher
impl RefUnwindSafe for PasswordHasher
impl Send for PasswordHasher
impl Sync for PasswordHasher
impl Unpin for PasswordHasher
impl UnsafeUnpin for PasswordHasher
impl UnwindSafe for PasswordHasher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more