An advanced, high-performance Python application designed for lossless image encryption and decryption using bitwise XOR operations. It includes robust metrics analysis tools, visual leakage evaluation, and batch empirical processing.
- ⚡ Lossless Cryptography: Direct bitwise XOR operations guarantee pixel-perfect reconstruction of decrypted images.
- 📊 Empirical Metric Evaluator: Computes Shannon Entropy (average/channel-wise), contrast, and color complexity over image batches.
- 🛡️ Visual Leakage Analyzer: Evaluates encryption quality differences when using simple keys vs. complex keys.
- 📈 Flattest Histogram Verification: Measures uniformity standards to identify potential statistical vulnerabilities.
git clone https://github.com/your-username/image-encryption.git
cd "Image encryption"Ensure you have Python 3.8+ installed, then run:
pip install -r requirements.txtAlternatively, install directly:
pip install numpy Pillowpython main.pyWhen you launch main.py, you will be greeted with the following interactive modes:
Image Encryption
1. Single image encrypt/decrypt
2. Empirical Analysis Run
3. Demonstrate Visual Leakage
4. Exit
To ensure maximum cryptographic strength, the tool evaluates images using:
| Metric | Target / Optimal Value | Purpose |
|---|---|---|
| Shannon Entropy |
|
Measures how random/unpredictable the encrypted pixels are. |
| Histogram Uniformity | Lower StdDev is better | Indicates if pixel intensity frequencies are evenly distributed. |
| Color Complexity | Match target profile | Number of unique RGB colors present in the matrix. |
Here is a visual demonstration of the encryption and decryption pipeline output:
🔒 Encrypted Output (encrypted_result.png) |
🔓 Lossless Recovered Output (recovered_image.png) |
|---|---|
![]() |
![]() |
- Language: Python 3.8+
- Core Libraries:
numpy,PIL(Pillow) - Math & Statistics: Normalized Histogram Analysis, Bitwise XOR Matrix Transformations
Distributed under the MIT License. See LICENSE for more details.

