pub fn getpass(prompt: &CStr) -> Result<String, Error>Expand description
Reads a passphrase using readpassphrase(3), returning it as a String.
Internally, this function uses a buffer of PASSWORD_LEN bytes, allowing for passwords up to
PASSWORD_LEN - 1 characters (accounting for the C null terminator.) The passed flags are
always the defaults, i.e., RppFlags::ECHO_OFF.
§Security
If the zeroize feature of this crate is disabled, then this function can leak sensitive
data on failure, e.g. if the entered passphrase is not valid UTF-8. There is no way around this
(other than using the default zeroize feature), so if you must turn that feature off and are
concerned about this, then you should use the readpassphrase function instead.
The returned String is owned by the caller, and therefore it is the caller’s responsibility
to clear it when you are done with it, for example by using zeroize:
use zeroize::Zeroizing;
let pass = Zeroizing::new(getpass(c"Pass: ")?);