import string
from cryptography.fernet import Fernet
'''Creation and Calling of the encryption(discarded after calling)'''
'''def write_key():
key = Fernet.generate_key()
with open("key.key", "wb") as key_file:
key_file.write(key)**strong text**
write_key()'''
'''my function to decrypt the encoded password''' def decrp(): with open('sanvalley.txt', 'r') as secret: for row in secret: print(row.read(fer.decrypt(U.encode()).decode()) + '|' + (fer.decrypt(P.encode().decode()) + '\n'))
def load_key():
with open("key.key", "rb") as alpha_key:
real_key = alpha_key.read()
return real_key
master_pass = input('Lost in Soul Sand be everything, but the KEY! \n')
while master_pass == 'Soul':
key = load_key() + master_pass.encode()
fer = Fernet(key)
action = input('Add/View Soul?').lower().strip()
if action == None:
quit
try:
if action == 'add':
U = input('Soulname: ')
P = input('Soul Sand: ')
with open('sandvalley.txt','a') as f:
beta = str(f)
secret = fer.encrypt(beta.encode())
output = f.write(secret)
print('Souls saw the light')
print('Souls have ceased!')
if action == 'view':
with open('sanvalley.txt', 'r') as secret:
for row in secret:
decrp()
if action != 'view' or 'add':
print ('End')
except:
input == None
break
break
'''code does save it to the file but its not encrypted , neitther can i decrypt'''