inplace/inplace.rs
1// Copyright 2025 Steven Dee.
2//
3// This project is made available under a BSD-compatible license. See the
4// LICENSE file in the project root for details.
5//
6// The readpassphrase source and header are copyright 2000-2002, 2007, 2010
7// Todd C. Miller.
8
9use readpassphrase_3::{RppFlags, readpassphrase};
10#[cfg(feature = "zeroize")]
11use zeroize::Zeroizing;
12
13fn main() {
14 #[allow(unused_mut)]
15 let mut buf = vec![0u8; 256];
16 #[cfg(feature = "zeroize")]
17 let mut buf = Zeroizing::new(buf);
18 let password = readpassphrase(
19 c"Password: ",
20 &mut buf,
21 RppFlags::FORCEUPPER | RppFlags::ECHO_ON,
22 )
23 .expect("failed reading passphrase");
24 println!("{password}");
25}