Struct sequoia_openpgp::crypto::Password
source · pub struct Password(_);
Expand description
Holds a password.
Password
s can be converted from various types using From
.
The password is encrypted in memory and only decrypted on demand.
See mem::Encrypted
for details.
Examples
use sequoia_openpgp as openpgp;
use openpgp::crypto::Password;
// Convert from a &str.
let p: Password = "hunter2".into();
// Convert from a &[u8].
let p: Password = b"hunter2"[..].into();
// Convert from a String.
let p: Password = String::from("hunter2").into();
// ...
Implementations§
source§impl Password
impl Password
sourcepub fn map<F, T>(&self, fun: F) -> Twhere
F: FnMut(&Protected) -> T,
pub fn map<F, T>(&self, fun: F) -> Twhere
F: FnMut(&Protected) -> T,
Maps the given function over the password.
The password is stored encrypted in memory. This function temporarily decrypts it for the given function to use.
Examples
use sequoia_openpgp as openpgp;
use openpgp::crypto::Password;
let p: Password = "hunter2".into();
p.map(|p| assert_eq!(p.as_ref(), &b"hunter2"[..]));