A comprehensive, interactive toolkit for the cryptanalysis of polyalphabetic ciphers, with a focus on breaking Vigenère ciphers through statistical analysis and visualization. This application provides a suite of statistical tools to help users crack Vigenère ciphers by determining key lengths and finding optimal shifts through visual and mathematical analysis.
-
Key Length Detection:
- Friedman Test: Analyzes the Index of Coincidence (IC) to distinguish between random and monoalphabetic distributions.
- Substring Distance (Kasiski): Identifies repeated patterns and calculates the greatest common divisors of their distances.
-
Decryption Analysis:
- Frequency Analysis: Side-by-side bar chart comparison of ciphertext distribution vs. standard English frequencies.
- Chi-Square Goodness-of-Fit: Automatically identifies the statistically most likely shift for every key position.
-
Interactive UI:
- Real-time "Alphabet Sliders" to manually adjust the key.
- Live decrypted preview with grouped-text formatting for easier reading.
- Rich Markdown documentation built directly into the interface.
- Python 3.8+
- Markdown
- PyQt5
- PyQt5_sip
- Matplotlib
- Clone the repository:
git clone https://github.com/LucBennett/VigenereAnalyzer.git
cd VigenereAnalyzer- Install dependencies:
python3 -m venv ./venv # optional
source ./venv/bin/activate # optional
pip install -r requirements.txt- Run the application:
python3 VigenereBreaker.py-
Run the Application
python3 VigenereBreaker.py
-
Enter Ciphertext
- Paste your encrypted text into the Encrypted Text Input box.
- Make sure the correct alphabet is selected (default is A–Z).
-
Find the Key Length
- Click Friedman Test
- Look for the first significant peak in the Index of Coincidence graph
- If peaks appear at 4, 8, and 12 → the key length is 4
(Optional) Use Substring Distance to confirm the same key length.
-
Set the Key Length
- Select the discovered value in the Key Length dropdown in the main window.
-
Crack the Cipher
- Open Chi-Square Analysis
- For each key position:
- Click Apply Best Shift
- Click Next Position
- Repeat until all positions are solved.
The decrypted text updates live in the preview panel.
-
Verify and Adjust (Optional)
- Open Frequency Analysis if any letters look incorrect.
- Use the shift controls to fine-tune individual positions.
- When the preview reads as clear English, you’re done.
VigenereBreaker.py: The main application entry point and UI controller.FriedmanAnalysis.py: Logic for Index of Coincidence.SubstringDistance.py: Pattern matching and Kasiski examination.FrequencyAnalysis.py: Visual frequency comparison tools.ChiSquare.py: Statistical shift detection.AlphabetSlider.py: Custom UI component for key manipulation.