Skip to content

LucBennett/VigenereAnalyzer

Repository files navigation

Vigenère Cipher Analyzer 🔐

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.

✨ Features

  • 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.

🛠️ Installation

Prerequisites

  • Python 3.8+
  • Markdown
  • PyQt5
  • PyQt5_sip
  • Matplotlib

Setup

  1. Clone the repository:
git clone https://github.com/LucBennett/VigenereAnalyzer.git
cd VigenereAnalyzer
  1. Install dependencies:
python3 -m venv ./venv # optional
source ./venv/bin/activate # optional

pip install -r requirements.txt
  1. Run the application:
python3 VigenereBreaker.py

🖥️ Usage Guide

  1. Run the Application

    python3 VigenereBreaker.py
  2. Enter Ciphertext

    • Paste your encrypted text into the Encrypted Text Input box.
    • Make sure the correct alphabet is selected (default is A–Z).
  3. Find the Key Length

    1. Click Friedman Test
    2. 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.

  4. Set the Key Length

    • Select the discovered value in the Key Length dropdown in the main window.
  5. Crack the Cipher

    1. Open Chi-Square Analysis
    2. For each key position:
    • Click Apply Best Shift
    • Click Next Position
    1. Repeat until all positions are solved.

    The decrypted text updates live in the preview panel.

  6. 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.

🗂️ Project Structure

  • 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.

About

Cryptanalysis Toolkit for Polyalphabetic Ciphers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages