Skip to content

tasmaikeni13/violet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

License: Apache 2.0 Python

๐Ÿ’œ Violet: Cascade Electromechanical Cipher Machine

A beautiful, mathematically rigorous implementation of the cascade electromechanical cipher machine ๐Ÿ”โœจ

๐ŸŽฏ What is Violet?

Violet is a sophisticated Python implementation of a cascade electromechanical cipher machineโ€”the kind of machine that would've made cryptographers in the 20th century absolutely giddy with mathematical joy. It combines rotor-based encryption with stepping-switch mechanisms, all wrapped in a sleek, interactive GUI.

Whether you're interested in cryptography, historical cipher machines, or just want to play with some delightfully purple encryptionโ€”Violet has got you covered! ๐ŸŽจ

Key Features โœจ

  • ๐Ÿ” Advanced Encryption: Dual-stage cascade mechanism with rotor evolution and independent stepping-switch logic
  • ๐ŸŽฎ Interactive Studio: Beautiful Tkinter GUI for encrypting/decrypting messages in real-time
  • ๐Ÿ“Š Statistical Analysis: Deep dive into cipher characteristics and patterns
  • ๐Ÿงช Rigorous Testing: Comprehensive theorem validation and cryptographic testing
  • ๐ŸŽจ Gorgeous UI: Dark theme with lavender accents that don't hurt your eyes

๐Ÿš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/tasmaikeni13/violet.git
cd violet

# Install dependencies
python run.py

This will automatically check dependencies and install them if needed!

Running Violet

Interactive GUI mode (Violet Studio):

python violet_studio/app.py

Run cryptographic tests:

python violet_core/test_theorems.py

Statistical analysis:

python violet_core/statistical_analysis.py

Auto-launch everything:

python run.py

๐Ÿ—๏ธ Project Structure

violet/
โ”œโ”€โ”€ violet_core/              # ๐Ÿง  The heart of the machine
โ”‚   โ”œโ”€โ”€ violet_engine.py      # Core cipher engine & rotor mechanics
โ”‚   โ”œโ”€โ”€ statistical_analysis.py  # Cryptographic property analysis
โ”‚   โ”œโ”€โ”€ test_theorems.py      # Validation & theorem testing
โ”‚   โ””โ”€โ”€ plots/                # Generated analysis visualizations
โ”œโ”€โ”€ violet_studio/            # ๐ŸŽจ Interactive GUI
โ”‚   โ””โ”€โ”€ app.py                # Tkinter-based cipher interface
โ”œโ”€โ”€ docs/                     # ๐Ÿ“š Documentation
โ”‚   โ”œโ”€โ”€ VIOLET.pdf            # Research paper (foundational theory)
โ”‚   โ”œโ”€โ”€ how_it_works.html     # Detailed technical explanation
โ”‚   โ””โ”€โ”€ screenshots/          # UI screenshots
โ”œโ”€โ”€ requirements.txt          # Dependencies (numpy, scipy, matplotlib)
โ””โ”€โ”€ run.py                    # Unified launcher script

๐Ÿ“ฆ Dependencies

  • numpy - Lightning-fast numerical operations on permutations
  • scipy - Statistical computation and analysis
  • matplotlib - Beautiful visualization of cipher characteristics

All installed automatically via python run.py ๐ŸŽ‰

๐Ÿ”ฌ The Mathematics Behind It

Violet implements the cascade model:

$$E_t = \sigma_t \circ \rho_t$$

Where:

  • ฯ_t = Rotor stage (evolves over Zโ‚‚โ‚†^r)
  • ฯƒ_t = Stepping-switch stage (evolves over Zโ‚‚โ‚…^k)
  • Composed through elegant permutation mathematics

Each component works independently yet harmoniously to create a robust cipher. See VIOLET.pdf or how_it_works.html for the full technical deep-dive! ๐Ÿ“–

Launch the beautiful GUI

python violet_studio/app.py

Then enjoy the purple paradise of encrypted messages! ๐Ÿ’œ

๐Ÿงช Testing & Validation

Run the comprehensive test suite:

python violet_core/test_theorems.py

This validates:

  • โœ… Permutation correctness
  • โœ… Rotor stepping mechanics
  • โœ… Switching functions
  • โœ… Cipher composition properties

๐Ÿ“Š Statistical Analysis

Generate cryptographic property analysis:

python violet_core/statistical_analysis.py

Includes:

  • Distribution analysis of ciphertext
  • Rotor state transitions
  • Plugboard configuration validation
  • Visualizations saved to violet_core/plots/

๐ŸŽจ GUI Features

The Violet Studio provides:

  • Real-time encryption/decryption with live character-by-character processing
  • Configurable machine settings: rotor selection, plugboard swapping, switch positions
  • Statistical overlay: view frequency distributions and rotor states
  • Export functionality: save encrypted messages and configurations
  • Dark theme optimized for extended cryptography sessions

๐Ÿ“ธ Screenshots

๐Ÿ–ฅ Violet Studio Interface

Violet Studio


๐Ÿ“Š Live Cipher Analysis

Live Analysis


๐Ÿš€ Launcher Menu

Launcher


๐Ÿ“ˆ Statistical Validation Figures

Fixed-Point Distribution

Fixed Point Distribution


Index of Coincidence Convergence

Index of Coincidence


Letter Frequency Flattening

Letter Frequency


Avalanche / Diffusion Heatmap

Diffusion Heatmap


Cipher Machine Period Comparison

Period Comparison


Operational Key Entropy Comparison

Keyspace Comparison


๐Ÿงช Empirical Test Suite

Theorem Validation Output

Tests

๐Ÿ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

You're free to use, modify, and distribute this code in your projects! ๐ŸŽ“

๐Ÿค Contributing

Found a bug? Have an idea? Contributions are welcome!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-cipher)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-cipher)
  5. Open a Pull Request

๐ŸŽ“ Learning Resources

  • ๐Ÿ“„ Research Paper: VIOLET.pdf โ€” The foundational research paper on which this implementation is based. Start here for the mathematical theory!
  • Technical Documentation: how_it_works.html
  • Cryptographic Theory: Classic works on electromechanical ciphers
  • Source Code: Well-documented and cleanโ€”dive in and explore!

โญ Show Your Support

If you find Violet useful or just enjoy parsing permutations, please leave a star! It helps others discover this beautiful cipher machine. ๐ŸŒŸ


Made with ๐Ÿ’œ and a passion for cryptography

"The enemy is listening. Make sure Violet is talking." ๐Ÿ”โœจ