A Linux-based Python CLI tool that demonstrates image encryption using pixel manipulation techniques. This project focuses on educational cryptography, showing how pixel-level operations can protect image data and why simple substitution-based encryption has limitations.
This tool encrypts and decrypts images by modifying RGB pixel values using a symmetric key. Instead of scrambling pixel positions, it applies XOR-based substitution, preserving the spatial structure of the image while altering its color information.
This project was developed as part of a Cybersecurity Internship task to understand low-level image encryption concepts.
Pixel manipulation is a technique where:
Each pixel’s color values (R, G, B) are accessed directly
Mathematical or logical operations are applied to these values
Pixel positions remain unchanged
In this tool:
(R, G, B) → (R ⊕ key, G ⊕ key, B ⊕ key)
Where ⊕ represents the XOR (exclusive OR) operation.
This is expected behavior and an important learning outcome.
✔ What changes:
Pixel color values
Visual appearance (color distortion)
Pixel positions
Image structure
Object layout
This happens because the encryption uses substitution only, not permutation.
This demonstrates the limitation of simple pixel-based encryption and highlights the need for stronger techniques such as diffusion, pixel shuffling, or AES-based encryption.
The tool supports multiple key generation methods:
A numeric key (0–255) directly used for encryption.
Password is hashed using SHA-256
A numeric key is derived from the hash
Password is never stored or used directly
Password → SHA-256 → Numeric Key → Encryption
Cryptographically secure random key generation
Useful for session-based encryption
-- Python 3.x
-- Pillow (PIL)
-- Install dependency:
-- pip3 install pillow
python3 imgcrypt.py encrypt -i image.png -o encrypted.png --password cyber123
python3 imgcrypt.py decrypt -i encrypted.png -o decrypted.png --password cyber123
python3 imgcrypt.py encrypt -i image.png -o encrypted.png --random-key
python3 imgcrypt.py encrypt -i image.png -o encrypted.png --key 120
To run the tool like a native Linux command:
chmod +x imgcrypt.py dos2unix imgcrypt.py sudo mv imgcrypt.py /usr/local/bin/imgcrypt
Run from anywhere:
imgcrypt --help
-- Encrypt image using password
-- Observe color distortion without scrambling
-- Decrypt using the same password
-- Original image is restored perfectly
-- Understanding pixel-level image encryption
-- Difference between substitution and permutation
-- Why passwords must be converted into cryptographic keys
-- Importance of secure randomness
-- Limitations of simple encryption techniques
This project is intended for educational purposes only. It demonstrates basic image encryption concepts and should not be used for real-world secure communication.
Developed by Om Jadhav Cybersecurity Intern – Prodigy Infotech
Consider giving the repository a ⭐ and sharing feedback!