04-22: Encryption Toolkit¶
Implements Caesar cipher, ROT13, and Vigenère cipher in pure Python. Includes a frequency analysis tool and a Caesar shift guesser (uses the English letter-frequency assumption that 'e' is most common).
Topics covered: ord() / chr() · modular arithmetic · string iteration · Counter · multi-key poly-alphabetic substitution · while-loop key cycling
Difficulty: ⭐⭐ Intermediate
How to Run¶
Ciphers Compared¶
| Cipher | Key | Security | Example |
|---|---|---|---|
| Caesar | 1 integer (shift) | Very weak | "HELLO" → "KHOOR" (shift 3) |
| ROT13 | Fixed (13) | Very weak | "HELLO" → "URYYB" |
| Vigenère | Word/phrase | Moderate | "HELLO" + key "KEY" → "RIJVS" |
Key Concepts Practised¶
| Concept | Where used |
|---|---|
(ord(c) - ord('a') + shift) % 26 |
Caesar shift formula |
chr(base + shifted) |
Back to character |
Key cycling: key[key_index % len(key)] |
Vigenère key repeat |
Counter(letters).most_common() |
Frequency analysis |
Shift guessing: (cipher_pos - e_pos) % 26 |
Crack Caesar |