A simple Python tool to encrypt and decrypt files, embedding metadata (original filename and extension) directly in the payload. It also allows secure key generation with automatic clipboard copy for convenience.
- 🔑 Generate a strong symmetric key (Fernet) and copy it to clipboard.
- 🔒 Encrypt any file, preserving original filename and extension in metadata.
- 🔓 Decrypt files, automatically restoring the original name and extension.
- 🛡️ Prevents overwriting existing files with smart filename handling.
- Python 3.8+
- Packages:
pip install -r requirements.txtRun the script with Python:
python image_crypt.py <action> [options]Generate a new encryption key and copy it to your clipboard:
python image_crypt.py generate_keyYou will see a message that the key is copied. Save it safely! It’s required for decryption.
Encrypt a file with a key:
python image_crypt.py encrypt -i path/to/input_file -k YOUR_KEY [-o path/to/output_file]-i/--input: Path to the file to encrypt.-k/--key: Your encryption key (copied fromgenerate_key).-o/--output: Optional output filename. Default is<input>_enc.
Example:
python image_crypt.py encrypt -i secret.txt -k gtb7fd7AA5yog9-e93PsgQHsGd_NRVoTh9nIZOLRqew=Decrypt a file:
python image_crypt.py decrypt -i path/to/encrypted_file -k YOUR_KEY [-o path/to/output_hint]-i/--input: Path to the encrypted file.-k/--key: Your encryption key.-o/--output: Optional hint for output filename. If omitted, the original filename from metadata is used.
Example:
python image_crypt.py decrypt -i secret.txt_enc -k gtb7fd7AA5yog9-e93PsgQHsGd_NRVoTh9nIZOLRqew=- File metadata is stored inside the encrypted payload, so the original filename and extension are preserved during decryption.
- If a file with the output name already exists, the script automatically appends
(1),(2), etc., to avoid overwriting. - The key is sensitive: losing it means you cannot decrypt your files!
This project is open-source and free to use. No warranties provided. Use responsibly.