diff --git a/scripts/Password Manager/password_manager.py b/scripts/Password Manager/password_manager.py new file mode 100644 index 0000000..19ae107 --- /dev/null +++ b/scripts/Password Manager/password_manager.py @@ -0,0 +1,50 @@ +from cryptography.fernet import Fernet + +''' +def write_key(): + key = Fernet.generate_key() + with open("key.key", "wb") as key_file: + key_file.write(key)''' + + +def load_key(): + file = open("key.key", "rb") + key = file.read() + file.close() + return key + + +key = load_key() +fer = Fernet(key) + + +def view(): + with open('passwords.txt', 'r') as f: + for line in f.readlines(): + data = line.rstrip() + user, passw = data.split("|") + print("User:", user, "| Password:", + fer.decrypt(passw.encode()).decode()) + + +def add(): + name = input('Account Name: ') + pwd = input("Password: ") + + with open('passwords.txt', 'a') as f: + f.write(name + "|" + fer.encrypt(pwd.encode()).decode() + "\n") + + +while True: + mode = input( + "Would you like to add a new password or view existing ones (view, add), press q to quit? ").lower() + if mode == "q": + break + + if mode == "view": + view() + elif mode == "add": + add() + else: + print("Invalid mode.") + continue diff --git a/scripts/Password Manager/passwords.txt b/scripts/Password Manager/passwords.txt new file mode 100644 index 0000000..38d1f07 --- /dev/null +++ b/scripts/Password Manager/passwords.txt @@ -0,0 +1,2 @@ +joe|gAAAAABgjFWyJO-TuQzczus2VTKZEkiQm40dWlU49uG4s0KztOLsTMCXUDN7DSSytU7w9ArgVZzhvt3oivFfFty1DwO0yZ71Fw== +billy|gAAAAABgjFYUZ22T15aXZyx72CpbC0Rd6hRcxq82RiAMn5Pj2WoMyzy8zAInqvwhg04LNWsW7lnlx3_RHpEEQ9fzhIYG9F0-lA==