rpassword 7.5.0

Read passwords in console applications.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use rpassword::read_password;
use std::io::{self, Write};

fn prompt(s: &str) {
    print!("{}", s);
    io::stdout().flush().unwrap(); // need to flush because print!() doesn't flush
}

fn main() {
    println!("=== read_password() ===");
    prompt("Password: ");
    match read_password() {
        Ok(pass) => println!("You entered: '{}'", pass),
        Err(e) => eprintln!("Error: {}", e),
    }
}