Skip to content

Commit 58b2739

Browse files
authored
Update README.md
Signed-off-by: Aakash G <[email protected]>
1 parent 175a1a0 commit 58b2739

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

Image Encryption/README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# XOR Image Encryption/Decryption Tool 🔐🖼️
2+
3+
A simple Python-based tool to encrypt or decrypt image files using XOR bitwise operation. This is useful for understanding basic cryptographic principles, specifically symmetric encryption using XOR.
4+
5+
---
6+
7+
## 📌 How It Works
8+
9+
This tool reads an image file as raw binary data (`bytearray`), applies the XOR operation on each byte using a user-defined key (0–255), and saves the encrypted/decrypted result.
10+
11+
Since XOR is symmetric:
12+
> **(Encrypted Data ⊕ Key = Original Data)**
13+
> **(Original Data ⊕ Key = Encrypted Data)**
14+
15+
Running the tool again with the same key will decrypt the image.
16+
17+
---
18+
19+
## 🧰 Features
20+
21+
- XOR-based symmetric encryption and decryption.
22+
- Works with any binary file (JPG, PNG, etc.).
23+
- Minimal and beginner-friendly.
24+
- CLI-based tool, portable and no external dependencies.
25+
26+
---
27+
28+
## 📁 Folder Structure
29+
30+
```
31+
XOR_Image_Encryptor/
32+
33+
├── xor_image_encryptor.py # Main Python script
34+
└── README.md # Documentation
35+
```
36+
37+
---
38+
39+
## ▶️ Usage
40+
41+
### 1. **Run the Script**
42+
43+
```bash
44+
python xor_image_encryptor.py
45+
```
46+
47+
### 2. **Follow the Prompts**
48+
49+
```text
50+
Image Encryption/Decryption Tool
51+
Enter image path: input.jpg
52+
Enter output file path: output.jpg
53+
Enter a secret key (0-255): 123
54+
```
55+
56+
The output image will be saved to the specified path.
57+
58+
---
59+
60+
## 🧪 Example
61+
62+
```bash
63+
# Encrypt
64+
Enter image path: secret.jpg
65+
Enter output file path: encrypted.jpg
66+
Enter a secret key (0-255): 77
67+
68+
# Decrypt
69+
Enter image path: encrypted.jpg
70+
Enter output file path: decrypted.jpg
71+
Enter a secret key (0-255): 77
72+
```
73+
74+
`decrypted.jpg` should be visually identical to `secret.jpg`.
75+
76+
---
77+
78+
## ⚠️ Notes
79+
80+
- Key must be an integer between `0` and `255`.
81+
- Both encryption and decryption use the **same function**.
82+
- Ensure file paths are valid and accessible.
83+
84+
---
85+
86+
## 📚 Concepts Used
87+
88+
- **Byte-level file handling**
89+
- **XOR (`^`) operation**
90+
- **Symmetric encryption logic**
91+
- **Error handling with `try-except`**
92+
93+
---
94+
95+
## 🔐 Educational Use Only
96+
97+
This tool is **not secure for real-world encryption**. XOR with a single key is trivially breakable. It's intended for **educational** use only to understand basic encryption.
98+
99+
---
100+
101+
# Build by AAKASH

0 commit comments

Comments
 (0)