From 8c9c211c249b9f2a4616b341e6378177129f3a4e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 24 Feb 2018 15:21:18 +0100 Subject: Make password line invisible Instead of rendering the password string, hide it while allowing it to be copied. It is identified by the "p: " prefix, but nothing follows that. This allows you to run `passextract` without having to worry about others peering over your shoulder or about screen capture or recording hacks. I'll be adding a command line flag to force you to opt in to this feature, while keeping the old functionality the same. --- src/main.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 2a196d3..9b1fe59 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,6 +78,17 @@ fn parse_options(filename: &str) -> Vec { options } +/// Checks whether the given line starts with "p: " +/// +/// # Examples +/// +/// ``` +/// assert_eq!(is_password_line("p: secret"), true); +/// ``` +fn is_password_line(line: &str) -> bool { + line.starts_with("p: ") +} + fn main() { let args: Vec = env::args().collect(); @@ -110,7 +121,11 @@ fn main() { term.printline_with_cell(selection.x, selection.y, "->", knockout_cell); for (i, s) in options.iter().enumerate() { - term.printline(5, i + 2, s) + if is_password_line(s) { + term.printline(5, i + 2, "p: ") + } else { + term.printline(5, i + 2, s) + } } let evt = term.get_event(Duration::from_millis(100)).unwrap(); -- cgit v1.2.3