This Python script provides a basic example of file encryption and decryption using the Fernet symmetric key encryption algorithm from the cryptography library.
Make sure you have Python installed on your system.
pip install cryptography
- Run the script
python main.py
-
Generate a Key: The generated key will be saved to a file named encrypted_key.key.
-
Encrypt a File: Replace something.txt with the path to the file you want to encrypt. The encrypted file will be saved as encrypted_file.txt.
-
Decrypt a File: After encryption, you can decrypt the file using the same key. The decrypted file will be saved as decrypted_file.txt.
- main.py: The main Python script containing functions for key generation, key saving/loading, file encryption, and file decryption.
- encrypted_key.key: The file containing the generated encryption key.
- something.txt: The input file you want to encrypt.
- encrypted_file.txt: The encrypted output file.
- decrypted_file.txt: The decrypted output file.