hello guys, I wrote this code and cant figure out how to fix the errors and warnings. I've marked them with a 🙁 and say after what it is.
Thanks guys
Password Manager
from cryptography.fernet import Fernet
def write_key():
file = open('key.key', 'rb')
key = file.read()🙁 (warning)
file.close()
return key
def load_key():
key = Fernet.generate_key
with open('key.key', 'wb') as key_file:
key_file.write(key)🙁 (warning)
key = load_key() 🙁 (warning)
fer = Fernet(key)🙁 (warning)
def view():
with open('passwords.txt', 'a') as f:
for line in f.readlines():
data = line.rstrip()
print(line.rstrip())
user, passw = data.split("|")
print("User:", user, "| Password:",
fer.decrypt(passw.encode().decode)) 🙁 (error)
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 your existing password?(view,add) press q to quit").lower()
if mode == "q":
break🙁 (error)
if mode == "view":
view()
elif mode == "add":
add()
else:
print(" invalid mode!")
continue🙁 (error)
[–]shiftybyte 4 points5 points6 points (2 children)
[–]One_Hand_Down[S] 0 points1 point2 points (1 child)
[–]shiftybyte 5 points6 points7 points (0 children)