1use std::process::exit;
10
11use readpassphrase_3::{readpassphrase, Flags as RpFlags, PASSWORD_LEN};
12use zeroize::Zeroizing;
13
14fn main() {
15 let mut buf = Zeroizing::new(vec![0u8; PASSWORD_LEN]);
16 let password = Zeroizing::new(
17 readpassphrase(c"Password: ", &mut buf, RpFlags::empty())
18 .expect("failed reading passphrase")
19 .to_string(),
20 );
21 for _ in 0..5 {
22 let confirm = readpassphrase(c"Confirmation: ", &mut buf, RpFlags::REQUIRE_TTY)
23 .expect("failed reading confirmation");
24 if *password == confirm {
25 eprintln!("Passwords match.");
26 return;
27 }
28 eprintln!("Passwords don’t match.");
29 }
30 eprintln!("Too many attempts.");
31 exit(1);
32}