Enigma Simulation - EnigmaMachine Documentation

EnigmaMachine Class

The class EnigmaMachine implements an enigma machine. It requires several helper classes (EnigmaConfig and EnigmaRotor). It also uses the function in the file enigma_gui.py.

A configuration file is used to configure the enigma machine when it first starts up. It defines:

Configuration files are created using the create_enigma_config_file.py program.

EnigmaMachine Methods

__init__(configfile)
initialize and return an EnigmaMachine object.

display_internal_state()
displays current configuration/state of the rotor's, reflector, plugboard.

display_rotor_status()
display the current state of the rotor's. +Rotor name, start, and count.

char_to_idx(char)
returns a character's list index. If it does not exists in the alphabet, -1 is returned.

idx_to_char(idx)
return the alphabet character associated with the index.Limited to the enigma machine's alphabet. (Hardwired into the enigma machines configuration file.)

char_in_alphabet(char)
return True if the character is in the alphabet; Return False if the character it not in the alphabet.

advance_rotors()
advances the rotors one position. Every time the right rotor makes a complete revolution, the the middle rotor is advances one position. Every the the middle rotor makes a complete revolution, the left rotor is advanced one position. This cascade of rotor advancement continues until the rotors are reset.

advance rotor(rtr)
advances a specified rotor one position. True is returned of the rotor has made a complete revolution; False if it has not.

reset()
sets the simulation rotors to the builtin initial configuration.

set(names,starts)
sets the simulation rotors to a new configuration. New rotors (I, II, III, VI, V, VI, VII, VIII) and new starting positions (indexes). The new configuration information is not saved.

Note: the reset command sets the rotors to a builtin configuration. The set command allows the user to set any (legal) configuration.

names is a list of three legal rotor names. Rotor names are limited to I, II, III, IV, V, VI,VII, VIII. Order is important (left,middle,right rotors).

starts is a list of three legal rotor staring positions. Starting positions are list indexes. Starting positions (indexes) are limited to the size of the alphabet (0 to N-1). Order is important (left,middle,right rotors).

auto_advance_on()
auto_advance_off()
auto_advance_state()
returns the advancement (rotor rotation) flag. Used for debugging or experimenting.

sub_debug_on()
sub_debug_off()
sub_debug_state()
returns the display-character-substitution-detailed-information flag. (Substitution passes through the rotors, the reflector, and the plugboard.) Used for debugging or experimenting.

substitution(idx) performs character substitutions using the rotors, reflector, and plugboard. (In other words, encrypting/decrypting the character using multiple substitution ciphers.)