rpassword
allows you to safely read passwords in a console application on Linux, OSX and Windows.
rpassword
is made available free of charge. You can support its development through Liberapay 💪
Add rpassword
as a dependency in Cargo.toml:
toml
[dependencies]
rpassword = "5.0"
Use rpassword
within your code:
```rust extern crate rpassword;
fn main() { // Prompt for a password on TTY (safest but not always most practical when integrating with other tools or unit testing) let pass = rpassword::readpasswordfrom_tty(Some("Password: ")).unwrap(); println!("Your password is {}", pass);
// Prompt for a password on STDOUT
let pass = rpassword::prompt_password_stdout("Password: ").unwrap();
println!("Your password is {}", pass);
// Prompt for a password on STDERR
let pass = rpassword::prompt_password_stderr("Password: ").unwrap();
println!("Your password is {}", pass);
// Read a password without prompt
let pass = rpassword::read_password().unwrap();
println!("Your password is {}", pass);
} ```
The full API documentation is available at https://docs.rs/rpassword.
We welcome contribution from everyone. Feel free to open an issue or a pull request at any time.
Here's a list of existing rpassword
contributors:
Thank you very much for your help! :smiley: :heart:
The source code is released under the Apache 2.0 license.