def main(): """ defining program entry """ f = open("key.pass", "r") if f.read() == ".\n": """ if its the users first time using this program, it will ask them to create a master password, the program will create a key out of the master password. """ print("Looks like its your first time using this password manager.") print("To get started, why don't you go ahead and create a password?") password = input("Password: "******"key.pass", "w") x.write(str(encrypt(password))) x.close() os.system("clear") main() else: print("Version:", _version) # print version print("To continue you have to login!") # ask the user to login password = input("Password: "******"utf-8")).hexdigest() # generate key from password key = base64.urlsafe_b64encode(key.encode("utf-8")) os.system("clear") f = open("key.pass", "r") if encrypt(password) == f.read(): f.close() while True: shell = input(f"{Fore.RED}>>> {Style.RESET_ALL}") if shell == "list" or shell == "ls": try: passwrd = open("passwords.txt", "r") for line in passwrd.readlines(): data = Fernet(key).decrypt(line.encode("utf-8")) print(data.decode()) print() passwrd.close() del data except: print( "unable to read and decrypt stored passwords!\nHave you changed your master password?\nRead the read me file!" ) elif "add" in shell: with open("passwords.txt", "ab") as i: i.write( Fernet(key).encrypt(shell[4:].encode("utf-8")) + "\n".encode("utf-8")) i.close() print("password added!\n") elif shell == "clear" or shell == "cls": os.system("clear") elif shell == "help": print(help_page) elif shell == "logout": print("Logging out!") os.system("clear") main() elif shell == "wipe": ask = input( "Are you sure you want to wipe all stored passwords? [Y/N] " ) if ask.lower() == "y": print( "Enter your master password to confirm its really you!" ) auth = input("Password: "******"passwords.txt", "w") as f: f.write("") f.close() print() else: print( "Password is not correct!\nCanceling operation!\n" ) else: print("Operation canceled by user!\n") elif shell == "update": print("updating...") os.system("python3 updater.py") print("update finished!") elif "remove" in shell: print("Command not implemented yet!\n") elif shell == "": pass elif shell == "restart": os.system("clear") main() elif shell == "export": data = [] with open("exported passwords.txt", "wb") as ex: f = open("passwords.txt", "rb") for line in f.readlines(): data.append(line) f.close() for line in data: ex.write(Fernet(key).decrypt(line)) ex.write("\n".encode("utf-8")) ex.close() del data else: print("Unknown command!\n") else: print("Authentication Failure!") f.close() input() os.system("clear") main()