This Python tool provides a flexible way to encrypt and decrypt files. It supports two methods of key management:
secret.key
).By combining both methods into a single script, users can choose the approach that best fits their needs, balancing convenience and security.
Clone the repository
git clone https://github.com/Vikranth3140/Encryption-Decryption-Tool.git
Install Required Libraries
Install the cryptography
library using pip:
pip install cryptography
The script is executed via the command line and supports the following operations:
-g
: Generate a Fernet key and save it to secret.key
.-e
: Encrypt a file.-d
: Decrypt a file.-k
: Use the stored key method.-p
: Use the password-based key derivation method.Before encrypting files using the stored key method, you need to generate a key.
python script.py -g
Output:
Encryption key generated and saved to 'secret.key'.
secret.key
file secure. If it's lost or compromised, encrypted data cannot be decrypted or may be at risk.python script.py -e -k <filename>
<filename>
: The path to the file you want to encrypt.secret.key
.python script.py -e -p <filename>
A-Z
).a-z
).0-9
).!@#$%^&*()
).Example:
python script.py -e -p confidential.txt
Output:
Enter password for encryption:
Password must be at least 8 characters long.
Please choose a stronger password.
Enter password for encryption:
Confirm password:
File 'confidential.txt' encrypted successfully as 'confidential.txt.encrypted' using password-based key derivation.
python script.py -d -k <filename>.encrypted
<filename>.encrypted
: The path to the encrypted file.secret.key
.python script.py -d -p <filename>.encrypted
Example:
python script.py -d -p confidential.txt.encrypted
Output:
Enter password for decryption:
File 'confidential.txt.encrypted' decrypted successfully as 'confidential.txt.decrypted' using password-based key derivation.
Generate a Key
python script.py -g
Encrypt a File
python script.py -e -k report.pdf
Decrypt the File
python script.py -d -k report.pdf.encrypted
Encrypt a File
python script.py -e -p notes.txt
Decrypt the File
python script.py -d -p notes.txt.encrypted
The GUI provides the following features:
Browse Files:
Encrypt Button:
Decrypt Button:
Password-Based Encryption:
When encrypting a file via the GUI:
Stored Key Method:
secret.key
file must be kept secure. If an unauthorized person accesses this file, they can decrypt any files encrypted with it.secret.key
file means losing access to all encrypted data. Ensure you have a secure backup.Password-Based Key Derivation:
General Recommendations:
Chunked File Processing:
Integrity Verification:
Graphical User Interface (GUI):
Batch Processing:
"Password must contain at least one uppercase letter.":
A-Z
)."Password must be at least 8 characters long.":
"Passwords do not match":
"Incorrect password or corrupted file":
"Decryption failed. Invalid key or corrupted file":
"Key file 'secret.key' not found":
python script.py -g
before encrypting or decrypting with the stored key method.This script is licensed under the MIT License.
Thank you for using this encryption tool. Your feedback and contributions are welcome!