Cryptography & OOP Simulation

CC-Enigma Machine (CryptoCrackers v1)

An object-oriented Python implementation of the classic electro-mechanical German Enigma encryption machine.

Python Object-Oriented Programming Cryptography Algorithms

Project Overview

The CC-Enigma Machine is a highly accurate software simulation of the physical Enigma rotor cipher machine used during World War II. Built entirely in Python using clean object-oriented design principles, this project models the complete electrical signal path—including the plugboard, multiple shifting rotors with mechanical notches, and a symmetric reflector.

Due to the mechanical design of the physical machine, Enigma encryption is entirely symmetrical: if you pass plaintext through the machine under a specific key configuration, it outputs ciphertext. If you reset the rotors to the exact same starting configuration and input the ciphertext, it deciphers back to the original plaintext. This emulator models that behavior flawlessly.

Technical Architecture & The Signal Path

To encrypt a single letter, the program emulates the continuous electrical path of the mechanical machine, passing indices through four distinct physical modules:

Input Key
Plugboard (Forward)
Rotors I-II-III (Forward)
Reflector (Mirror)
Rotors III-II-I (Reverse)
Plugboard (Reverse)
Output Ciphertext

Key Components

Key Python Implementation

Below is the core of the cryptographic pipeline inside the Enigma orchestrator. This block manages the physical rotor stepping rotation logic before passing the character index bidirectionally through the virtual circuitry:

# Emulating the mechanical rotation and electrical signal path
def encode(self, c):
    c = c.upper()
    if not c.isalpha():
        return c

    # Step the fast rotor first
    self.rotors[0].rotate()

    # Double-stepping anomaly: physical quirk of the middle rotor
    if self.rotors[1].base[0] in self.rotors[1].notch:
        self.rotors[1].rotate()

    # Cascade the stepping rotation down the rotor bank
    for i in range(len(self.rotors) - 1):
        if self.rotors[i].turnover:
            self.rotors[i].turnover = False
            self.rotors[i + 1].rotate()

    # Bidirectional Signal Routing:
    index = self.plugboard.forward(c)          # Forward through Plugboard
    for r in self.rotors:
        index = r.forward(index)               # Forward through Rotors
    
    index = self.reflector.forward(index)      # Reflected Backwards
    
    for r in reversed(self.rotors):
        index = r.reverse(index)               # Reversed back through Rotors
        
    c = self.plugboard.reverse(index)          # Reversed back through Plugboard
    return c

Key Engineering Takeaways