Skip to content

ShakalBhau0001/caesar-cipher-cryptanalysis-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” Caesar Cipher Cryptanalysis (Python)

An educational Python implementation of Caesar Cipher brute-force cryptanalysis. This project demonstrates how classical encryption can be broken using exhaustive search and simple English frequency scoring.

It is designed as a learning and academic project to understand why classical ciphers are insecure and how attackers analyze encrypted text โ€” not as a real-world attack tool.


๐Ÿงฑ Project Structure

caesar-cipher-cryptanalysis-python/
โ”‚
โ”œโ”€โ”€ assets/               # Screenshots
โ”œโ”€โ”€ app.py                # Brute-force Basic CLI Version
โ”œโ”€โ”€ interactive.py        # Rich-powered CLI
โ”œโ”€โ”€ requirements.txt      # Dependencies
โ”œโ”€โ”€ LICENSE               # Project license
โ””โ”€โ”€ README.md             # Project documentation

โœจ Features

๐Ÿ” Full Brute-Force Search

  • Tests all 25 possible Caesar shifts
  • Supports both:
    • L โ†’ Left shift
    • R โ†’ Right shift
  • Automatically evaluates all possible plaintext candidates

๐Ÿง  English Scoring System

  • Uses frequency-based heuristic scoring
  • Prioritizes common English letters (E, T, A, O, I, N, etc.)
  • Rewards spaces and readable structure
  • Ranks outputs automatically

๐Ÿ“Š Auto-Ranked Results

  • Sorts plaintext candidates by likelihood
  • Displays top possible decryptions
  • Removes mirror duplicate results

๐Ÿงฎ Educational Focus

  • Demonstrates cryptanalysis workflow
  • Shows weakness of classical substitution ciphers
  • Reinforces modular arithmetic concepts
  • Clean and modular Python implementation

๐ŸŽจ Rich CLI (Interactive Mode)

  • Beautiful colored terminal UI using Rich
  • Displays key matrix in a structured table ๐Ÿ”ฅ
  • Interactive prompts with validation
  • Clean and readable output panels

โšก Dual Mode Support

  • ๐Ÿงผ Basic CLI โ†’ Lightweight, no dependencies
  • ๐ŸŽจ Rich CLI โ†’ Enhanced UI with colors and structured display

๐Ÿ›  Technologies Used

Technology Role
Python 3 Core programming language
ord() / chr() Character-to-ASCII conversion
Modular Arithmetic Circular alphabet shifting (% 26)
Heuristic Scoring English-likeness evaluation
Rich Styled CLI, colors, panels

๐Ÿ“Œ Purpose of This Project

This project is built to:

  • Understand Caesar Cipher weaknesses
  • Learn brute-force cryptanalysis
  • Explore basic frequency analysis concepts
  • Simulate attacker perspective ethically
  • Strengthen Python logic and modular design skills

โš ๏ธ This project is intended strictly for educational and cybersecurity learning purposes.


โ–ถ๏ธ How to Run

1๏ธโƒฃ Clone the repository

git clone https://github.com/ShakalBhau0001/caesar-cipher-cryptanalysis-python.git

2๏ธโƒฃ Navigate to the project folder

cd caesar-cipher-cryptanalysis-python

3๏ธโƒฃ Install Dependencies

pip install rich

OR

pip install -r requirements.txt

4๏ธโƒฃ Running the Project

๐Ÿงผ Basic CLI Version

python app.py

๐ŸŽจ Rich Interactive Version

python interactive.py

5๏ธโƒฃ Follow the prompts for Basic CLI Version

  • Provide any Caesar-encrypted message
  • View automatically ranked possible plaintexts
  • Analyze shift and direction results

๐Ÿ”Ž Example

Enter Caesar cipher text: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD

Top Possible Plaintexts:

Shift  3 | Dir R | Score  72 | THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
Shift 23 | Dir L | Score  72 | THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
...

โš ๏ธ Limitations

  • English scoring is heuristic-based (not statistical-grade)
  • Works only for Caesar Cipher
  • Not designed for real-world encrypted systems
  • CLI-based interaction only

๐ŸŒŸ Future Improvements

  • Implement full frequency distribution comparison
  • Add dictionary-based validation
  • Support file input
  • Add support for other classical ciphers
  • Convert into reusable Python module
  • Add Rich tables for result visualization

โš ๏ธ Disclaimer

This project is created for educational and cybersecurity learning purposes only. It demonstrates the inherent weakness of classical substitution ciphers such as Caesar Cipher. It must not be used for unauthorized access, malicious activity, or real-world security attacks.


๐Ÿ“ธ Preview

Rich CLI Preview


๐Ÿชช Author

Shakal Bhau

GitHub: ShakalBhau0001


โญ Support

If you like this project, consider giving it a โญ on GitHub!


About

Educational Python implementation of Caesar Cipher cryptanalysis with automatic brute-force and English frequency scoring to demonstrate weaknesses of classical encryption.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages