enigma.rotor¶
-
class
enigma.rotor.
Rotor
(name: str, pattern: str, notches: str = None, alphabet: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')¶ Create an Enigma Machine Rotor
- Parameters
pattern – The rotor pattern specified as a case-sensitive string (the standard alphabet is uppercase, so unless you specify a custom alphabet pass the pattern as uppercase too)
notches – Notches for this rotor, specified as a string (if there are multiple characters in the string, the rotor will have multiple notches) None or an empty string can also be passed if this rotor shouldn’t have a notch.
alphabet – Input alphabet for this rotor. For standard enigma machine rotors this is simply the roman alphabet, however custom rotors can be easily created supporting additional characters.
-
encode_left_to_right
(char: str)¶ Encode a character left-to-right through this rotor.
- Parameters
char – Character to be encoded
-
encode_right_to_left
(char: str)¶ Encode a character right-to-left through this rotor.
- Parameters
char – Character to be encoded
-
get_position
()¶ Get the current position for this rotor
-
get_setting
()¶ Get initial setting for this rotor
-
has_notch
()¶ Return True if this rotor has any notches
-
is_on_notch
()¶ Return True if the current position is on a notch
-
rotate
()¶ Trigger a rotation of this rotor. It will wrap around if it reaches the last position available
-
set_position
(position: str)¶ Set initial position for this rotor
- Parameters
position – Initial position for the rotor, as a character
-
set_setting
(setting: int)¶ Set initial setting for this rotor
- Parameters
setting – Initial setting for the rotor, as an integer