pub struct Password(/* private fields */);Expand description
A password used to unlock a crate::Keystore.
The password is stored in a Zeroizing<Vec<u8>>; the underlying memory is
wiped when the Password is dropped. Password is Clone so callers may
retain a copy for later use (e.g., re-locking with the same password);
both copies are zeroized on drop.
§Construction
Use any of the From impls:
use dig_keystore::Password;
let from_str: Password = Password::from("abc");
let from_string: Password = Password::from(String::from("abc"));
let from_slice: Password = Password::from(b"abc".as_slice());
let from_vec: Password = Password::from(b"abc".to_vec());
let from_new: Password = Password::new(b"abc");§UTF-8 vs arbitrary bytes
Password accepts arbitrary byte sequences. Argon2id hashes raw bytes, so
non-UTF-8 passwords work. The optional password-strength feature (which
wires zxcvbn) requires UTF-8 and falls back to
an empty-string score for non-UTF-8 bytes.
Implementations§
Source§impl Password
impl Password
Sourcepub fn new(bytes: impl AsRef<[u8]>) -> Self
pub fn new(bytes: impl AsRef<[u8]>) -> Self
Wrap any byte sequence as a Password.
Copies the input bytes into a freshly-allocated zeroizing buffer. The
caller’s original bytes are not wiped — callers managing particularly
sensitive memory should zeroize the source themselves after passing it
to Password::new.