enigma.enigma

An Enigma machine.

Module Contents

Classes

Enigma

An Enigma machine.

Rotor

A single rotor for scrambling an input pin to a different output.

Attributes

ROTOR_LEN

enigma.enigma.ROTOR_LEN
class enigma.enigma.Enigma

An Enigma machine.

press_key(self, letter_input)

Press a key on the machine.

Parameters

letter_input (str) – the key pressed

Returns

the letter bulb that lights up

Return type

str

step_rotors(self)

Step rotors forward.

Step first rotor, turning over rotors 2 and 3 if required.

class enigma.enigma.Rotor(wiring, turnover_notch_letter)

A single rotor for scrambling an input pin to a different output.

wire_up(self, output_letter_order)

Wire up the rotor.

Create a dict to implement the input/output wiring of the rotor pins. For example: “0”: “7”, “1”: “17”, “2”: “2” :param output_letter_order: order of the 26 output pins :type output_letter_order: str

step(self)

Advance the rotor by one.

trace(self, input_pin_pos0)

Trace an input pin through the rotor to an output pin.

Parameters

input_pin_pos0 (int) – input pin from the previous component (machine or previous rotor) relative to position 0 of the rotor

Returns

output pin relative to position 0 of rotor

Return type

int