XOR-based encryption with integrity verification
AKA a command line app in Python to encrypt plain text files into hexadecimal using a key or keyfile.
🔒 XOR-based file encryption/decryption
🔑 Supports direct keys or key files
✅ SHA-256 checksum verification
🔄 Multiple encryption passes
📁 Handles both text and binary files
📊 Progress indicators (optional)
🛡️ Key strengthening via SHA-256 hashing
- Python 3.6+
- Recommended packages (from bash): pip install tqdm colorama
Save [encryptor.py] to your preferred directory
-
Encryption - python encryptor.py encrypt input.txt encrypted.bin -k "your-secret-key"
-
Decryption - python encryptor.py decrypt encrypted.bin output.txt -k "your-secret-key"
# Encryption with key file
python encryptor.py encrypt message.txt encrypted.bin -K keyfile.txt
# Decryption with key file
python encryptor.py decrypt encrypted.bin message.txt -K keyfile.txt
# Encryption with integrity check
python encryptor.py encrypt data.dat encrypted.bin -k password123 --checksum
# Decryption with verification
python encryptor.py decrypt encrypted.bin restored.dat -k password123 --checksum
python encryptor.py encrypt sensitive.doc encrypted.bin -k "long passphrase" --passes 5
usage: encryptor.py [-h] [-k KEY | -K KEY_FILE] [-p PASSES] [-c] [--no-progress] {encrypt,decrypt} input_file output_file
Required arguments:
{encrypt,decrypt} Operation mode
input_file Input file path
output_file Output file path
Security options: -k KEY, --key KEY Direct encryption key
-K KEY_FILE, --key-file KEY_FILE
File containing encryption key
-p PASSES, --passes PASSES
Number of encryption passes (default: 3)
-c, --checksum Enable integrity checks (SHA-256)
Optional features: --no-progress Disable progress indicators
🔐 XOR encryption provides basic protection - not suitable for highly sensitive data
🗝️ Key strength is crucial - use long, complex keys/passphrases
🔄 Multiple passes slightly improve security through obscurity
✅ Always use --checksum for critical files
📝 Works with both text and binary files
📄 Checksum files are automatically named:
-- Encryption: checksum-<output_file>
-- Decryption: checksum-<input_file>
🐇 Handles large files efficiently
📈 Progress bars automatically disabled for non-TTY environments
❌ "Checksum mismatch" = Corrupted file or wrong key
❗ "Invalid hex format" = File not properly encrypted
🔑 "Key file not found" = Verify key file path
- Create test file:
echo "Secret Data" > original.txt
- Encrypt with checksum:
python encryptor.py encrypt original.txt encrypted.bin -k "p@ssw0rd!" --checksum
- Verify files created:
encrypted.bin
checksum-encrypted.bin
- Decrypt with verification:
python encryptor.py decrypt encrypted.bin restored.txt -k "p@ssw0rd!" --checksum
This tool provides basic file obfuscation and should not be used for protecting highly sensitive information. Always combine with other security measures for critical data protection.