From 75dfd0c758c5cb50522bec9ce81c460dd7030d9c Mon Sep 17 00:00:00 2001 From: crp3844 Date: Wed, 7 Sep 2022 11:04:47 -0400 Subject: [PATCH] added encrypt and decrypt testing --- bitwardenBackup.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/bitwardenBackup.py b/bitwardenBackup.py index 2e71825..aa61269 100644 --- a/bitwardenBackup.py +++ b/bitwardenBackup.py @@ -294,6 +294,12 @@ if __name__ == "__main__": action="store_true", dest="decrypt", ) + parser.add_option( + "-e", + "--encrypt", + action="store_true", + dest="encrypt", + ) parser.add_option( "-m", "--message", @@ -320,8 +326,21 @@ if __name__ == "__main__": client.open() #print(encrypt(client, "test")) - if opts.decrypt: - print(decrypt(client, opts.message)) + if opts.encrypt: + while True: + passphrase = getpass("Please enter your pool/dataset unlock passphrase to encrypt: ") + passphrase2 = getpass("Please enter the passphrase again: ") + if passphrase == passphrase2: + break + else: + print("The passphrases do not match, please try again.") + encrypted_passphrase = encrypt(client, passphrase) + print("Your encrypted passphrase: {}".format(encrypted_passphrase)) + sys.exit(0) + elif opts.decrypt: + passphrase = input("Please enter the encryted passphrase to decrypt: ") + decrypted_passphrase = decrypt(client, passphrase) + print("Your decrypted passphrase: {}".format(decrypted_passphrase)) sys.exit(0) @@ -366,6 +385,7 @@ if __name__ == "__main__": elif user_input.casefold() == "n": account_details = ask_for_account_details() config = configparser.ConfigParser() + config.read(secrets_ini_file) config.add_section(account_details["encrypted_account_email_address"]) for key in account_details.keys(): if not key == "encrypted_account_email_address": @@ -376,6 +396,7 @@ if __name__ == "__main__": elif user_input.casefold() == "d": config = configparser.ConfigParser() + config.read(secrets_ini_file) account_section_to_delete = select_account(accounts, "delete") print("Are you sure you wish to delete {} account? ".format(account_section_to_delete)) confirmation = input("y/n> ")