Page:
Caesar Cipher
Pages
API Rate Limiter
API Security Scanner
Base64 Tool
Bug Bounty Platform
Caesar Cipher
Certification Roadmaps
Contributing
DNS Lookup
Docker Security Audit
Encrypted P2P Chat
Getting Started
Home
Keylogger
Metadata Scrubber Tool
Network Traffic Analyzer
Project Roadmap
SIEM Dashboard
Simple Port Scanner
Simple Vulnerability Scanner
Tools and Resources
1
Caesar Cipher
CarterPerez-dev edited this page 2026-02-11 04:56:38 -05:00
Caesar Cipher
Classical encryption tool with brute-force cracking and frequency analysis.
Overview
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
Tech Stack
| Technology | Version | Purpose |
|---|---|---|
| Python | 3.12+ | Core language |
| Typer | - | CLI framework |
| Rich | - | Terminal formatting and tables |
Features
Core Functionality
- 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
Security Relevance
- 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
Architecture
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)
Quick Start
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 decryptions
Project Structure
caesar-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
Development
# Run tests
uv run pytest tests/ -v
# Linting
uv run ruff check .
# Format
uv run ruff format .
Source Code
Navigation
Beginner Projects
- Simple Port Scanner
- Keylogger
- Caesar Cipher
- DNS Lookup Tool
- Vulnerability Scanner
- Metadata Scrubber
- Network Traffic Analyzer
- Base64 Encoder/Decoder
Intermediate Projects
Advanced Projects
Guides
Resources
Progress: 14/60
©AngelaMos | CertGames.com | CarterPerez-dev | 2026