-
-
Notifications
You must be signed in to change notification settings - Fork 127
Caesar Cipher
CarterPerez-dev edited this page Feb 11, 2026
·
1 revision
Classical encryption tool with brute-force cracking and frequency analysis.
A CLI tool implementing the Caesar cipher with encrypt, decrypt, and crack commands. The crack feature uses chi-squared frequency analysis to automatically determine the shift key by ranking all 26 possible decryptions against English letter frequency distributions.
Status: Complete | Difficulty: Beginner
| Technology | Version | Purpose |
|---|---|---|
| Python | 3.12+ | Core language |
| Typer | - | CLI framework |
| Rich | - | Terminal formatting and tables |
- Encrypt text with a given shift key
- Decrypt text when the key is known
- Brute-force crack by trying all 26 shifts
- Chi-squared frequency analysis for ranking results
- File I/O support
- ROT13 is still used in forums and email
- Frequency analysis applies to other substitution ciphers in CTF challenges
- Brute-forcing small key spaces applies to weak passwords and short PINs
- Foundation for understanding why simple substitution ciphers fail
User Command
β
main.py (Typer CLI: encrypt, decrypt, crack)
β
ββββββββββββββββ¬βββββββββββββββ¬βββββββββββββββ
β cipher.py β analyzer.py β constants.py β
β Encrypt/ β Frequency β English β
β decrypt β analysis + β letter β
β logic β chi-squared β frequencies β
ββββββββββββββββ΄βββββββββββββββ΄βββββββββββββββ
β
utils.py (File I/O, input validation)
cd PROJECTS/beginner/caesar-cipher
# Install dependencies
uv sync
# Encrypt
caesar-cipher encrypt "HELLO WORLD" --key 3
# Output: KHOOR ZRUOG
# Decrypt
caesar-cipher decrypt "KHOOR ZRUOG" --key 3
# Output: HELLO WORLD
# Crack without knowing the key
caesar-cipher crack "KHOOR ZRUOG"
# Shows ranked table of all 26 possible decryptionscaesar-cipher/
βββ src/caesar_cipher/
β βββ cipher.py # Core encryption/decryption logic
β βββ analyzer.py # Frequency analysis for cracking
β βββ constants.py # English letter frequencies, alphabet
β βββ main.py # CLI commands
β βββ utils.py # File I/O and input validation
βββ tests/
βββ pyproject.toml
# Run tests
uv run pytest tests/ -v
# Linting
uv run ruff check .
# Format
uv run ruff format .Β©AngelaMos | CertGames.com | CarterPerez-dev | 2026