i know how to save a users input to a text file but how do i encrypt it? here is what i have for saving a users input to text file. i tried
f.encrypt("Passwords_log.txt" but had no results
import time password1 = input("Please type a password: ") print("Your password has passed the verification!") time.sleep(1) print("Saving and encrypting password...") time.sleep(2) f=open("Passwords_log.txt",'a') f.write(password) f.write('\n') f.close() print("Done!")
There are some Python packages worth checking out that deal with cryptography.
A simple example from
cryptography would be the following:
from cryptography.fernet import Fernet key = Fernet.generate_key() cipher_suite = Fernet(key) cipher_text = cipher_suite.encrypt(b"A really secret message. Not for prying eyes.") plain_text = cipher_suite.decrypt(cipher_text)
External links referenced by this document: