pub struct PasswordHash { /* private fields */ }
Expand description
A versionned password hash. Can be used to validate a password without storing the password.
Implementations§
Source§impl PasswordHash
impl PasswordHash
Sourcepub fn verify_password(&self, password: &[u8]) -> bool
pub fn verify_password(&self, password: &[u8]) -> bool
Verify if the PasswordHash
matches with the specified password. Should execute in constant time.
§Arguments
password
- The password to verify.
§Returns
Returns true if the password matches and false if it doesn’t.
§Example
use devolutions_crypto::password_hash::{hash_password, PasswordHashVersion};
let password = b"somesuperstrongpa$$w0rd!";
let hashed_password = hash_password(password, 10000, PasswordHashVersion::Latest);
assert!(hashed_password.verify_password(b"somesuperstrongpa$$w0rd!"));
assert!(!hashed_password.verify_password(b"someweakpa$$w0rd!"));
Trait Implementations§
Source§impl Clone for PasswordHash
impl Clone for PasswordHash
Source§fn clone(&self) -> PasswordHash
fn clone(&self) -> PasswordHash
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PasswordHash
impl Debug for PasswordHash
Source§impl From<PasswordHash> for Vec<u8>
impl From<PasswordHash> for Vec<u8>
Source§fn from(data: PasswordHash) -> Self
fn from(data: PasswordHash) -> Self
Serialize the structure into a Vec<u8>
, for storage, transmission or use in another language.
Source§impl HeaderType for PasswordHash
impl HeaderType for PasswordHash
Auto Trait Implementations§
impl Freeze for PasswordHash
impl RefUnwindSafe for PasswordHash
impl Send for PasswordHash
impl Sync for PasswordHash
impl Unpin for PasswordHash
impl UnwindSafe for PasswordHash
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