pub struct Password { /* private fields */ }Expand description
A password whose backing memory is securely zeroed when dropped.
This newtype is the primary way to pass passwords into hash,
hash_with_salt, and verify. By accepting Password by value, the
API guarantees that the caller’s plaintext copy is destroyed (via
crypto::secure_zero_bytes()) before the function returns, even on panic.
§Examples
use crypt_sha512::{hash, verify, Password};
let h = hash(Password::from("hunter2"), None);
assert_eq!(verify(Password::from("hunter2"), &h), Ok(true));Password deliberately does not implement Clone, Debug, or
core::fmt::Display to discourage accidental duplication or logging of
plaintext secrets.
Implementations§
Trait Implementations§
Source§impl From<&str> for Password
impl From<&str> for Password
Source§fn from(s: &str) -> Self
fn from(s: &str) -> Self
Copy the string slice into a new Password. The copy will be zeroed on
drop, but the caller’s original &str is unaffected — prefer
Password::from(String) when you
own the buffer.
Auto Trait Implementations§
impl Freeze for Password
impl RefUnwindSafe for Password
impl Send for Password
impl Sync for Password
impl Unpin for Password
impl UnsafeUnpin for Password
impl UnwindSafe for Password
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