|
| 1 | +# 🛡️ Caesar Cipher Tool |
| 2 | + |
| 3 | +A command-line utility to **encrypt** and **decrypt** messages using the Caesar Cipher algorithm. Great for learning basic cryptography, creating puzzles, or encoding secret messages within a local or collaborative environment. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 🔐 What is Caesar Cipher? |
| 8 | + |
| 9 | +Caesar Cipher is a substitution cipher where each letter in the plaintext is shifted by a fixed number (shift key) of positions down the alphabet. |
| 10 | + |
| 11 | +### Example (Shift = 3): |
| 12 | +- A → D |
| 13 | +- B → E |
| 14 | +- X → A |
| 15 | +- Z → C |
| 16 | + |
| 17 | +> **Encryption**: Shift letters forward |
| 18 | +> **Decryption**: Shift letters backward |
| 19 | +
|
| 20 | +--- |
| 21 | + |
| 22 | +## 📦 Features |
| 23 | + |
| 24 | +- Encrypt or decrypt any string using a simple shift |
| 25 | +- Supports both uppercase and lowercase |
| 26 | +- Leaves spaces, numbers, and punctuation unchanged |
| 27 | +- Command-line interface for real-time usage |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## ⚙️ Usage |
| 32 | + |
| 33 | +### 🔧 Requirements |
| 34 | +- Python 3.x installed |
| 35 | + |
| 36 | +### 🏃 Run via Command Line |
| 37 | + |
| 38 | +```bash |
| 39 | +python caesar_cipher_tool.py <mode> <shift> "<text>" |
| 40 | +```` |
| 41 | + |
| 42 | +* `<mode>`: `e` for encrypt, `d` for decrypt |
| 43 | +* `<shift>`: Number of positions to shift |
| 44 | +* `<text>`: The message to process (wrap in quotes) |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## 🧪 Examples |
| 49 | + |
| 50 | +### Encrypt: |
| 51 | + |
| 52 | +```bash |
| 53 | +python caesar_cipher_tool.py e 4 "meet at library at 5pm" |
| 54 | +``` |
| 55 | + |
| 56 | +Output: |
| 57 | + |
| 58 | +``` |
| 59 | +Result: qiix ex plevvex ex 5ts |
| 60 | +``` |
| 61 | +
|
| 62 | +### Decrypt: |
| 63 | +
|
| 64 | +```bash |
| 65 | +python caesar_cipher_tool.py d 4 "qiix ex plevvex ex 5ts" |
| 66 | +``` |
| 67 | + |
| 68 | +Output: |
| 69 | + |
| 70 | +``` |
| 71 | +Result: meet at library at 5pm |
| 72 | +``` |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +## 💡 Real-world Scenario |
| 77 | + |
| 78 | +You and a friend agree on a shift value (e.g., 4). You encrypt a secret note and send it. Your friend uses the same script and shift value to decrypt it. |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## 🛠️ How It Works |
| 83 | + |
| 84 | +The script: |
| 85 | + |
| 86 | +1. Loops through each character in the message. |
| 87 | +2. Applies a shift based on encryption or decryption mode. |
| 88 | +3. Converts characters using ASCII math and wraps alphabetically using `% 26`. |
| 89 | +4. Non-alphabet characters are preserved. |
| 90 | + |
| 91 | +```python |
| 92 | +chr((ord(char) - base + shift) % 26 + base) |
| 93 | +``` |
| 94 | + |
| 95 | +* `ord(char)` – ASCII of char |
| 96 | +* `base` – `ord('a')` or `ord('A')` |
| 97 | +* `shift` – Provided shift value |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## 🧑🎓 Author |
| 102 | + |
| 103 | +Built by Aakash — focused on cybersecurity, scripting, and real-world learning through hands-on tools. |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | + |
0 commit comments