Skip to content

kevinkoosk/encryptor.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Encryptor.py - File Encryption Tool

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.

Features

🔒 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

Installation

Requirements

  • Python 3.6+
  • Recommended packages (from bash): pip install tqdm colorama

Download

Save [encryptor.py] to your preferred directory

Basic Usage

  1. Encryption - python encryptor.py encrypt input.txt encrypted.bin -k "your-secret-key"

  2. Decryption - python encryptor.py decrypt encrypted.bin output.txt -k "your-secret-key"

Advanced Features

Key File Usage

# 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

Checksum Verification

# 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

Multiple Pass Encryption

python encryptor.py encrypt sensitive.doc encrypted.bin -k "long passphrase" --passes 5

Command Reference

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

Important Notes

Security Considerations

🔐 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

File Handling

📝 Works with both text and binary files

⚠️ Encrypted files use .bin extension by convention

📄 Checksum files are automatically named:

-- Encryption: checksum-<output_file>

-- Decryption: checksum-<input_file>

Performance

🐇 Handles large files efficiently

📈 Progress bars automatically disabled for non-TTY environments

Troubleshooting

❌ "Checksum mismatch" = Corrupted file or wrong key

❗ "Invalid hex format" = File not properly encrypted

🔑 "Key file not found" = Verify key file path

Example Workflow

  1. Create test file:

echo "Secret Data" > original.txt

  1. Encrypt with checksum:

python encryptor.py encrypt original.txt encrypted.bin -k "p@ssw0rd!" --checksum

  1. Verify files created:

encrypted.bin

checksum-encrypted.bin

  1. Decrypt with verification:

python encryptor.py decrypt encrypted.bin restored.txt -k "p@ssw0rd!" --checksum

Disclaimer

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.

About

A command line app in Python to encrypt plain text files into hexadecimal using a key or keyfile.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages