2016-03-15 20:36:33 +00:00
|
|
|
extern crate termion;
|
2016-03-07 17:42:11 +00:00
|
|
|
|
2016-07-23 15:40:27 +01:00
|
|
|
use termion::input::TermRead;
|
2016-03-07 17:42:11 +00:00
|
|
|
use std::io::{Write, stdout, stdin};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let stdout = stdout();
|
|
|
|
let mut stdout = stdout.lock();
|
2016-03-08 07:51:34 +00:00
|
|
|
let stdin = stdin();
|
|
|
|
let mut stdin = stdin.lock();
|
2016-03-07 17:42:11 +00:00
|
|
|
|
2016-12-21 13:20:48 +00:00
|
|
|
stdout.write_all(b"password: ").unwrap();
|
2016-03-07 17:42:11 +00:00
|
|
|
stdout.flush().unwrap();
|
|
|
|
|
2016-03-07 21:19:35 +00:00
|
|
|
let pass = stdin.read_passwd(&mut stdout);
|
2016-03-07 17:42:11 +00:00
|
|
|
|
2016-03-08 07:51:34 +00:00
|
|
|
if let Ok(Some(pass)) = pass {
|
2016-12-21 13:20:48 +00:00
|
|
|
stdout.write_all(pass.as_bytes()).unwrap();
|
|
|
|
stdout.write_all(b"\n").unwrap();
|
2016-03-07 17:42:11 +00:00
|
|
|
} else {
|
2016-12-21 13:20:48 +00:00
|
|
|
stdout.write_all(b"Error\n").unwrap();
|
2016-03-07 17:42:11 +00:00
|
|
|
}
|
|
|
|
}
|