This project is a simple Image Encryption and Decryption Tool developed using Python and the Pillow (PIL) library. The tool secures images by applying XOR-based pixel manipulation techniques to every pixel in the image.
The same operation is used for both encryption and decryption because XOR is a reversible operation.
- Encrypt images using XOR pixel manipulation
- Decrypt encrypted images using the same secret key
- Supports RGB image processing
- User-friendly command-line interface
- Error handling for invalid file paths and keys
- Python 3
- Pillow (PIL) Library
git clone https://github.com/Abhishith999/SCT_CS_2
cd SCT_CS_2pip install -r requirements.txtEach pixel in the image contains RGB values.
The program performs an XOR operation between each RGB value and the user-provided secret key.
Example:
new_r = r ^ key
new_g = g ^ key
new_b = b ^ keyBecause XOR is reversible:
- Applying the same key again decrypts the image
- The original image is restored
image-encryption-tool/
│
├── image_encryption.py
├── README.md
├── input_images/
├── output_images/
python image_encryption.pyEnter 'E' for encryption or 'D' for decryption
- Input image path
- Output image path
- Numerical secret key
Enter 'E' for encryption or 'D' for decryption: E
Enter the path of the image to be encrypted: input.jpg
Enter the path where the encrypted image will be saved: encrypted.jpg
Enter the numerical key: 45
Enter 'E' for encryption or 'D' for decryption: D
Enter the path of the image to be decrypted: encrypted.jpg
Enter the path where the decrypted image will be saved: decrypted.jpg
Enter the numerical key: 45
The program handles:
- Invalid file paths
- Incorrect key input
- Unexpected runtime errors
Through this project, the following concepts were learned:
- Image processing using Pillow
- Pixel manipulation techniques
- XOR encryption logic
- File handling in Python
- Exception handling
- Command-line interaction
- GUI-based interface
- Multiple encryption algorithms
- Password-based key generation
- Drag-and-drop image support
- Batch image encryption
Developed as part of the Cyber Security Internship Program at SkillCraft Technology.