An AI-powered tool for encrypting, decrypting, and auto-cracking classical ciphers — Caesar, Atbash, Affine, Vigenère, Hill, Nihilist, Baconian, Porta, Pollux, Morbit, Fractionated Morse, Aristocrats, Patristocrats, Xenocrypts, and more — plus a solver for cryptarithms (puzzles like SEND + MORE = MONEY). A chatbot explains each step so users learn the underlying technique, not just get an answer.
The project has three parts working together:
- A deterministic cipher engine — pure math/code that encrypts and decrypts any cipher when the key is known. No AI involved, just correct implementations of each algorithm.
- A cryptanalysis solver — for ciphers meant to be "cracked" without a key (mainly Aristocrats/Patristocrats and Vigenère), using frequency analysis, quadgram scoring, and hill-climbing/simulated annealing search. This is the actual AI/ML part of the project.
- A cryptarithm solver — solves letter-arithmetic puzzles (e.g.
SEND + MORE = MONEY, where each letter stands for a unique digit) using constraint-satisfaction search rather than language-frequency techniques.
Classical ciphers are a great sandbox for combining algorithmic thinking (implementing exact cipher math) with applied AI/ML techniques (frequency analysis, language modeling, and search-based optimization for code-breaking). This project was built to explore both sides — clean deterministic implementations plus a from-scratch cryptanalysis engine — wrapped in a conversational interface that explains its reasoning.
A chatbot layer (powered by the Anthropic API) sits on top of both: it parses what the user is asking for in plain English, calls the right cipher or solver function, and explains the result step by step — like a tutor, not just a calculator.
This project is split across two repositories:
ai-cipher-decoder-frontend— plain HTML/CSS/JS. No framework, no build step.ai-cipher-decoder-backend— Python + FastAPI, hosts the cipher engine, solvers, and chatbot orchestration.
ai-cipher-decoder-frontend/
├── index.html # landing page
├── practice.html # practice mode (timer, random ciphertext, reveal steps)
├── solve.html # manual encrypt/decrypt tool
├── cryptarithm.html # cryptarithm puzzle solver (SEND + MORE = MONEY style)
├── chat.html # chatbot interface
├── css/ # per-page + shared styles
│ └── cryptarithm.css
├── js/
│ ├── api.js # fetch wrappers calling the backend
│ ├── ciphers-ui.js # shared cipher-selector logic
│ ├── solve.js
│ ├── practice.js
│ ├── cryptarithm.js # puzzle input parsing + rendering solved digit mapping
│ ├── chat.js
│ └── utils.js
└── assets/
ai-cipher-decoder-backend/
├── app/
│ ├── main.py # FastAPI entrypoint
│ ├── ciphers/ # keyed encrypt/decrypt for every supported cipher
│ ├── solvers/ # quadgram scoring, hill-climbing, Aristocrat/Vigenère crackers
│ │ └── cryptarithm_solver.py # constraint-satisfaction solver for letter-arithmetic puzzles
│ ├── data/ # English + Spanish quadgram frequency tables
│ ├── chatbot/ # Anthropic API client, tool definitions, orchestrator
│ ├── routes/ # /encrypt, /decrypt, /solve, /cryptarithm, /chat endpoints
│ └── tests/
├── requirements.txt
└── .env.example
cd ai-cipher-decoder-backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env # add your ANTHROPIC_API_KEY
uvicorn app.main:app --reloadBackend runs at http://localhost:8000.
No build step required — just open the HTML files directly in a browser, or serve the folder locally:
cd ai-cipher-decoder-frontend
python -m http.server 5500Then visit http://localhost:5500. Make sure js/api.js points at your backend URL (http://localhost:8000 while developing).
- Phase 1 — Cipher engine: Caesar, Atbash, Affine, Vigenère
- Phase 1 — Cipher engine: Hill, Nihilist, Baconian, Porta, Pollux, Morbit, Fractionated Morse
- Phase 2 — Aristocrat/Patristocrat auto-solver (quadgram + hill-climbing)
- Phase 2 — Vigenère auto-solver (Kasiski + Index of Coincidence)
- Phase 2 — Xenocrypt (Spanish) solver
- Phase 2 — Cryptarithm solver (constraint-satisfaction search over letter-digit assignments)
- Phase 3 — Chatbot orchestration via Anthropic API tool use
- Phase 4 — Practice mode with timer and step-by-step reveal
- Deploy frontend (Netlify/Vercel/GitHub Pages) + backend (Render/Railway)
- practicalcryptography.com — quadgram frequency data and cryptanalysis background
- dCode.fr — reference implementations for edge-case checking
- Anthropic API docs — chatbot tool-use integration
TBD