aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-02-24 15:21:18 +0100
committerTeddy Wing2018-02-24 15:21:18 +0100
commit8c9c211c249b9f2a4616b341e6378177129f3a4e (patch)
tree90b6981bbaf0e5e311dd519275f725c02fcb0e45
parent5351bbfcf1bcabcb6632768b23e606d4cb53540b (diff)
downloadPassextract-8c9c211c249b9f2a4616b341e6378177129f3a4e.tar.bz2
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.
-rw-r--r--src/main.rs17
1 files changed, 16 insertions, 1 deletions
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<String> {
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<String> = 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();