added encrypt and decrypt testing
This commit is contained in:
@@ -294,6 +294,12 @@ if __name__ == "__main__":
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
dest="decrypt",
|
dest="decrypt",
|
||||||
)
|
)
|
||||||
|
parser.add_option(
|
||||||
|
"-e",
|
||||||
|
"--encrypt",
|
||||||
|
action="store_true",
|
||||||
|
dest="encrypt",
|
||||||
|
)
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-m",
|
"-m",
|
||||||
"--message",
|
"--message",
|
||||||
@@ -320,8 +326,21 @@ if __name__ == "__main__":
|
|||||||
client.open()
|
client.open()
|
||||||
#print(encrypt(client, "test"))
|
#print(encrypt(client, "test"))
|
||||||
|
|
||||||
if opts.decrypt:
|
if opts.encrypt:
|
||||||
print(decrypt(client, opts.message))
|
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)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
@@ -366,6 +385,7 @@ if __name__ == "__main__":
|
|||||||
elif user_input.casefold() == "n":
|
elif user_input.casefold() == "n":
|
||||||
account_details = ask_for_account_details()
|
account_details = ask_for_account_details()
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
config.read(secrets_ini_file)
|
||||||
config.add_section(account_details["encrypted_account_email_address"])
|
config.add_section(account_details["encrypted_account_email_address"])
|
||||||
for key in account_details.keys():
|
for key in account_details.keys():
|
||||||
if not key == "encrypted_account_email_address":
|
if not key == "encrypted_account_email_address":
|
||||||
@@ -376,6 +396,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
elif user_input.casefold() == "d":
|
elif user_input.casefold() == "d":
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
config.read(secrets_ini_file)
|
||||||
account_section_to_delete = select_account(accounts, "delete")
|
account_section_to_delete = select_account(accounts, "delete")
|
||||||
print("Are you sure you wish to delete {} account? ".format(account_section_to_delete))
|
print("Are you sure you wish to delete {} account? ".format(account_section_to_delete))
|
||||||
confirmation = input("y/n> ")
|
confirmation = input("y/n> ")
|
||||||
|
|||||||
Reference in New Issue
Block a user