Enigma Components

class component.Steckerbrett(name: str = '', wiring: Union[str, Dict[str, str]] = '', alphabet: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', notify: Optional[Callable[[str], None]] = None)[source]

Bases: component.Umkehrwalze

Represents a Steckerbrett (plugboard)

Wheel Controls

Item

Value

encryption

forward and backward

ring

none

notches

none

Parameters
  • name – name of the Steckerbrett

  • wiring – wiring of the Steckerbrett, positions related to the alphabet

  • alphabet – unencoded alphabet to be used

  • notify – notification function (e.g. print)

static Mark_1(replacement: bool = True, alphabet: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', notify: Optional[Callable[[str], None]] = None) component.Steckerbrett[source]

Random Initialization of a Mark 1 Steckerbrett (crytomuseumSB) The contacts are splitted into 2 separated groups (sockets 1-13 and sockets 14-26)

static Mark_2(replacement: bool = True, alphabet: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', notify: Optional[Callable[[str], None]] = None) component.Steckerbrett[source]

Random Initialization of a Mark 2 Steckerbrett (crytomuseumSB) The 52 contacts are connected in unlimited fashion

static Mark_3(nConnections: int = 10, alphabet: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', notify: Optional[Callable[[str], None]] = None) component.Steckerbrett[source]

Random Initialization of a Mark 3 Steckerbrett (crytomuseumSB) The 26 contacts are cross-connected, i.e. MU is combined with UM

addMark3Setting(src: str, tgt: str) None[source]

Add one setting to a Steckerbrett (crytomuseumSB)

clearMark3Setting(c: str) None[source]

Clear one setting of a Steckerbrett (crytomuseumSB)

exchangeMark3Setting(c1: str, c2: str) None[source]

Exchanges 2 settings of a Steckerbrett (crytomuseumSB)

isMark1() bool[source]

Checks, if the steckerbrett is of type Mark1

Returns

indicator

isMark3() bool[source]

Checks, if the steckerbrett is of type Mark3

Returns

indicator

nConnections() int[source]

Counts the number of connections of a steckerbrett

property rwiring: str
Getter

Returns the reverse wiring

class component.Umkehrwalze(name: str = '', wiring: Union[str, Dict[str, str]] = '', alphabet: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', notify: Optional[Callable[[str], None]] = None)[source]

Bases: object

Represents an Umkehrwalze (UKW == reflector)

Wheel Controls

Item

Value

encryption

forward only

ring

none

notches

none

Parameters
  • name – name of the Umkehrwalze

  • wiring – wiring of the Umkehrwalze, positions related to the alphabet

  • alphabet – unencoded alphabet to be used

  • notify – notification function (e.g. print)

property alphabet: str
Getter

Returns the alphabet of the engine

Setter

None

chain(forward: bool = True) List[Tuple[component.Component, bool]][source]

Creates a chain of visited components

Parameters
  • forward – direction

  • _chain – current chain list (do not use)

Returns

(component, forward) list

dictToWiring(wiringDict: Dict[str, str]) None[source]

Creates a dictionary starting from the wiring

Parameters

wiringDict – dictionary of (at least connected) wirings

encode(c: str, forward: bool, componentOnly: bool = False) str[source]

Runs forward or backward through a component

Parameters
  • c – single character

  • forward – direction

  • componentOnly – do not go to next or previous component

Returns

encoded character (mapped back to the alphabet)

property name: str
Getter

Returns the name of the componenrt :setter: None

property nextComponent: str
Getter

Returns the next component in the chain

Setter

Sets wiring and reverse wiring, if any

property numberOfPositions: int
Getter

Returns the number of positions, usually len(alphabet)

Setter

None

property prevComponent: str
Getter

Returns the previous component in the chain

Setter

Sets wiring and reverse wiring

property wiring: str
Getter

Returns the wiring

Setter

Sets wiring and reverse wiring

wiringToDict(connectedOnly: bool = False) Dict[str, str][source]

Creates a dictionary starting from the wiring

Parameters

connectedOnly – include only characters not connected to itself

Returns

dictionary of alphabet vs. wiring character

class component.Walze(name: str = '', wiring: Union[str, Dict[str, str]] = '', ringstellung: Optional[str] = None, notches: str = '', alphabet: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', notify: Optional[Callable[[str], None]] = None)[source]

Bases: component.Zusatzwalze

Represents a Walze (rotor)

Wheel Controls

Item

Value

encryption

forward and backward

ring

yes

notches

yes

Parameters
  • name – name of the walze

  • wiring – wiring of the walze, positions related to the alphabet

  • ringstellung – visible character at the beginning, position related to the alphabet

  • notches – visible characters for the notches, positions related to the alphabet

  • alphabet – unencoded alphabet to be used

  • notify – notification function (e.g. print)

property notches: str
Getter

Returns the notches

Setter

None

step() None[source]

Steps the Walze and inititiates of the next Walze if available

III II I <– wheel order A D O A D P A D Q A E R <– 1st step of middle wheel B F S <– 2nd step of middle wheel B F T B F U

stepN(n: int) None[source]

Steps the Walze n times

class component.Zusatzwalze(name: str = '', wiring: Union[str, Dict[str, str]] = '', ringstellung: Optional[str] = None, alphabet: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', notify: Optional[Callable[[str], None]] = None)[source]

Bases: component.Steckerbrett

Represents an Zusatzwalze (ZW == extra rotor)

Wheel Controls

Item

Value

encryption

forward and backward

ring

yes

notches

none

Parameters
  • name – name of the Zusatzwalze

  • wiring – wiring of the Zusatzwalze, positions related to the alphabet

  • alphabet – unencoded alphabet to be used

  • notify – notification function (e.g. print)

property ringstellung: str
Getter

Returns the ringstellung

Setter

Sets the ringstellung