Skip to content

ShakalBhau0001/rail-fence-cipher-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” Rail Fence Cipher Implementation (Python)

A complete and educational Python implementation of the Rail Fence Cipher encryption algorithm. This project demonstrates zigzag-based transposition encryption and decryption using structured logic.

It is created as a learning and academic project to understand how classical transposition cryptography works internally, not as a production-ready security system.


๐Ÿงฑ Project Structure

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

โœจ Features

๐Ÿ”ข Rail-Based Zigzag Pattern

  • Uses a numerical key (number of rails)
  • Writes plaintext in a zigzag pattern
  • Rearranges characters without substitution
  • Demonstrates classical transposition technique

๐Ÿ”’ Encryption

  • Removes spaces before processing
  • Arranges characters across rails
  • Reads row by row to produce ciphertext
  • Maintains character order logic correctly

๐Ÿ”“ Decryption

  • Reconstructs zigzag pattern
  • Restores original message structure
  • Reverses encryption algorithm accurately

๐ŸŽจ 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

๐Ÿงฎ Educational Focus

  • Clean and readable logic
  • Modular encryption & decryption functions
  • Ideal for beginners in cryptography
  • No external dependencies

๐Ÿ›  Technologies Used

Technology Role
Python 3 Core programming language
List Logic Zigzag rail structure handling
Rich Styled CLI, colors, panels

๐Ÿ“Œ Purpose of This Project

This project is built to:

  • Understand classical transposition ciphers
  • Learn zigzag-based encryption logic
  • Explore position-based cryptographic techniques
  • Study reversible transformation algorithms

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


โ–ถ๏ธ How to Run

1๏ธโƒฃ Clone the repository

git clone https://github.com/ShakalBhau0001/rail-fence-cipher-python.git

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

cd rail-fence-cipher-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

  • Choose direction:
    • E โ†’ Encrypt
    • D โ†’ Decrypt
  • Enter your message
  • Enter number of rails
  • View the result

๐Ÿ”Ž Example

Encryption :

Encrypt or Decrypt (E/D): E
Enter message:  MEET ME TOMORROW
Enter number of rails: 2

Encrypted message: MEMTMROETEOORW

Decryption :

Encrypt or Decrypt (E/D): D
Enter message: MEMTMROETEOORW
Enter number of rails: 2

Decrypted message: MEETMETOMORROW

โš ๏ธ Limitations

  • Not secure for real-world use
  • Classical cipher (easily breakable)
  • Small key space (limited rails)
  • Removes spaces during processing
  • CLI-based interaction only

๐ŸŒŸ Future Improvements

  • Preserve spaces and formatting
  • Add brute-force rail testing mode
  • Add frequency analysis support
  • Add input validation for rail values
  • Create GUI version
  • Combine into a classical cryptography toolkit

โš ๏ธ Disclaimer

This implementation is created for educational and learning purposes only. The Rail Fence Cipher is historically significant but cryptographically insecure and must not be used to protect real-world sensitive data.


๐Ÿ“ธ Preview

Rich CLI Preview


๐Ÿชช Author

Shakal Bhau

GitHub: ShakalBhau0001


โญ Support

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


About

A Python implementation of the classical Rail Fence cipher with encryption and decryption support. Built for educational purposes to understand zigzag-based transposition and historical cryptographic techniques.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages