Skip to content

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3DES (Triple DES) Visualizer

An interactive, educational GUI application built with Python and CustomTkinter designed to demystify the 3DES cryptographic algorithm. This tool visualizes the Feistel network, subkey generation, and the inner workings of the $f$-function for beginners -- for both encryption and decryption.

Screenshots

Encrypt Cycle View -- the block-level EDE pipeline, Encrypt(K1) -> Decrypt(K2) -> Encrypt(K3):

Encrypt Cycle View

Encrypt Round Detail -- Key 1's key schedule and full $f$-function breakdown, live at any round:

Encrypt Round Detail

Decrypt Round Detail -- the mirrored decryption pipeline, subkeys consumed in reverse order (K16 down to K1):

Decrypt Round Detail

Features

  • Session keys, generated for you: 3 keys are generated automatically each session (shown read-only in hex) -- there's no key entry, so you can't accidentally use a weak or malformed key. A "Generate New Keys" button gets you a fresh set at any time.
  • Full-message encryption: Type any length of plaintext; it's PKCS#7 padded and split into as many 64-bit blocks as needed, then encrypted end to end.
  • Encrypt Cycle View: See the block-level EDE pipeline -- Encrypt(K1) -> Decrypt(K2) -> Encrypt(K3) -- with a block navigator to inspect any block's input/output at each stage.
  • Encrypt Round Detail: Zoom into Key 1's 16 Feistel rounds for any block -- watch the key schedule (PC-1, per-round rotation, PC-2) and the full $f$-function breakdown (Expansion, XOR, S-box substitution, P-permutation) update live as you step through rounds.
  • Decrypt Cycle View / Decrypt Round Detail: The same two views, mirrored for the DED decryption pipeline (Decrypt(K3) -> Encrypt(K2) -> Decrypt(K1)), proving the process is genuinely reversible -- not just re-running encryption.

What This Project Demonstrates

  • Cryptographic understanding, not just library usage: every DES table (IP, FP, PC-1, PC-2, E-box, P-box, all 8 S-boxes), the Feistel round structure, and the full key schedule are implemented from the FIPS-46 specification -- no pycryptodome/cryptography in the actual encryption logic. Correctness was verified against the official FIPS-46 known-answer test vector and cross-checked against an independent library implementation at every stage (key schedule, f-function, single DES, and full 3DES), not just "it runs without crashing."
  • Modular software architecture: each pipeline stage (bit utilities, key scheduling, the f-function, one Feistel round, single DES, the 3DES EDE/DED wrapper, the GUI) lives in its own module with a single responsibility -- the GUI can visualize any stage independently because the logic underneath never assumes a GUI exists.
  • GUI development with real interactivity: built with CustomTkinter, including dynamic tabbed views, live-updating text panels, and independent block/round navigators driven entirely by application state rather than hardcoded content.
  • Attention to correctness at the edges: PKCS#7 padding (including the edge case where a message is already block-aligned), input validation, and state clearing when keys are regenerated were all deliberately designed, not afterthoughts.

Project Structure

src/
├── main.py         # Entry point
├── gui.py          # CustomTkinter application (only file that imports the GUI toolkit)
├── triple_des.py   # 3DES EDE/DED orchestration: encrypt/decrypt, single-block and full-message
├── des.py          # Single DES: IP -> 16 rounds -> FP, encrypt and decrypt
├── des_round.py    # One Feistel round (L/R swap + XOR)
├── f_function.py   # The f-function: Expansion, XOR, S-boxes, P-permutation
├── key_schedule.py # Per-key subkey generation (PC-1, rotations, PC-2)
├── constants.py    # DES tables (IP, FP, PC-1, PC-2, E, P, S-boxes)
└── utils.py        # Bit-string helpers (permute, xor, rotate, PKCS#7 padding, conversions)

Each pipeline stage lives in its own module so the GUI can visualize it independently: key scheduling never touches the data block, the f-function never touches the Feistel swap logic, and single DES never touches the EDE/DED wrapper.

Installation & Running

  1. Clone the repository:

    git clone https://github.com/yourusername/3des-visualizer.git
    cd 3des-visualizer
  2. Set up a virtual environment and install dependencies:

    python -m venv venv
    source venv/bin/activate  # On Windows use: venv\Scripts\activate
    pip install -r requirements.txt
  3. Run the app:

    python src/main.py
  4. Type some plaintext and click Encrypt -- all four tabs (Encrypt Cycle View, Encrypt Round Detail, Decrypt Cycle View, Decrypt Round Detail) update together.

License

MIT -- see LICENSE.

About

A Python-based educational simulator mapping the 3DES cipher encoding pipeline. This application visualizes the step-by-step encryption process of Triple DES, highlighting key schedules, block transformations, and data cycles. Designed to help learners trace exactly how plaintext is scrambled through the legacy algorithm layers.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages