From d3cdc309ed26095e31cf41b403ae523d5be01b4d Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Tue, 17 Aug 2021 19:20:57 -0400 Subject: [PATCH] prompt user for encryption passkey if not provided --- src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 243a513..55be175 100644 --- a/src/main.rs +++ b/src/main.rs @@ -192,7 +192,9 @@ fn main() { accountmanager::ManifestAccountLoadError::MissingPasskey | accountmanager::ManifestAccountLoadError::DecryptionFailed, ) => { - error!("Incorrect passkey"); + if passkey.is_some() { + error!("Incorrect passkey"); + } passkey = rpassword::prompt_password_stdout("Enter encryption passkey: ").ok(); } Err(e) => { @@ -313,6 +315,16 @@ fn main() { manifest.save(&passkey).expect("Failed to save manifest."); return; } else if matches.is_present("encrypt") { + if passkey.is_none() { + loop { + passkey = rpassword::prompt_password_stdout("Enter encryption passkey: ").ok(); + let passkey_confirm = rpassword::prompt_password_stdout("Confirm encryption passkey: ").ok(); + if passkey == passkey_confirm { + break; + } + error!("Passkeys do not match, try again."); + } + } for entry in &mut manifest.entries { entry.encryption = Some(accountmanager::EntryEncryptionParams::generate()); }