I am making a password manager program (as chatGPT suggested) what its supposed to do when you first start is to make the file containing the "Master Password" encrypted, but when I go test the program and enter the new master password, it doesn't make the file.
Here is the code below:
import os
import fernet
# this will be the master password file, which contains the master password, but encrypted using fernet
masterPasswordFile = 'mstrpswd.faiK'
doesMasterPasswordExist = os.path.exists(masterPasswordFile)
# so we can break the program
while True:
if doesMasterPasswordExist == False: # this is self-explanatory
print('Looks like it`s your first time, please set up a master password before we gets started.')
masterPassword = str(input('--> '))
masterPassword_encrypted = fernet.Encrypter(masterPassword) # encrypt master password
newFile = open(f'{masterPasswordFile}', 'w')
newFile.write(masterPassword_encrypted) # write the encrpyted password
newFile.close()
continue
elif doesMasterPasswordExist == True:
print('What is your master password?')
user_mstrpswd = str(input('--> '))
mstrpswdFile = open(f'{masterPasswordFile}', 'r') # opens the file
masterPassword_encrypted_readFromFile = mstrpswdFile.read() # reads the password from file
mstrpswd_decrypted = fernet.Decrypter(masterPassword_encrypted_readFromFile) # decrypt it.
if mstrpswd_decrypted != user_mstrpswd:
print('Thats not right, try again.')
continue
else:
# actual code.
print('You`re in!')
It's still in the works, but I just wanted to see if it was functioning properly.