Function readpassphrase

Source
pub fn readpassphrase(prompt: &CStr, flags: RppFlags) -> Result<String, Error>
Expand description

Reads a passphrase using readpassphrase(3), returning it as a String. Internally uses a buffer of PASSWORD_LEN bytes, allowing for passwords up to PASSWORD_LEN - 1 characters (including the null terminator.)

§Security

The returned String is not cleared on success; it is the caller’s responsibility to do so, e.g.:

let pass = Zeroizing::new(readpassphrase(c"Pass: ", RppFlags::default())?);
Examples found in repository?
examples/echo_passphrase.rs (line 13)
11fn main() {
12    let password =
13        readpassphrase(c"Password: ", RppFlags::default()).expect("failed reading password");
14    println!("{password}");
15}