pub fn getpass(prompt: &CStr) -> Result<String, Error>Expand description
Reads a passphrase using readpassphrase(3), returning 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 NUL terminator.) Any additional characters
and the terminating newline are discarded.
§Errors
Returns Err if readpassphrase(3) itself failed or if the entered password is not UTF-8.
The former will be represented by Error::Io and the latter by Error::Utf8.
§Security
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:
let mut pass = getpass(c"Pass: ")?;
_ = pass;
pass.zeroize();