Engima module¶
M3 Enigma
class¶
-
class
ciphers.Engima.
M3
[source]¶ Bases:
flask_restful.Resource
Represents the Enigma Machine used by the Wehrmacht/Heer.
-
slow_rotor
¶ This is the leftmost rotor,the rotor that steps the least.
-
medium_rotor
¶ This is the middle rotor,the rotor that double steps.
-
fast_rotor
¶ This is the rightmost rotor, steps for every character.
-
reflector
¶ This is the chosen reflector, it defualts to B reflector.
-
stecker_board
¶ This is the generated stecker board.
-
fast_counter
¶ Counts the amount of times stepped for Fast Rotor
-
medium_counter
¶ Counts the amount of times stepped for Middle Rotor.
-
slow_counter
¶ Counts the amount of times stepped for Slowest Rotor.
-
right_rotor_ring
¶ Ring setting for the Fastest Rotor.
-
middle_rotor_ring
¶ Ring setting for the Slow Rotor.
-
left_rotor_ring
¶ Ring setting for the Slowest Rotor.
-
rotor_choices
¶ This is a dictionary of the five rotor’s wiring and the stepping position for each rotor.
-
reflector
This is a dictionary that stores the two reflectors used.
-
check_stecker_restrictions
(stecker_pair)[source]¶ Checks if user provided stecker board pairs is valid.
Parameters: stecker_pair – String that represent the stecker board pairs. Returns: True or False if the user provided values are valid.
-
create_stecker_board
(wire_pairing)[source]¶ Thanks to Brian Neal’s Enigma project as a reference steckerboard. Creates the Stecker Board based off the pairs provided by the User. Max amount of Pairs allowed are 10.
Parameters: wire_pairing – Space seperated String that contains max 10 pairs IOT populate the Steckerboard.Example “AB HG LK ZI”. Returns: No return values but can raise aborts if the request is malformed.
-
forward
(user_input)[source]¶ The character is passed through the machine right to left.
Parameters: user_input – The message to be passed through the machine. Returns: The char encoded/decoded is returned.
-
methods
= {'GET'}¶
-
reverse
(user_input)[source]¶ The character is passed through the machine left to right.
Parameters: user_input – The message to be passed through the machine. Returns: The char encoded/decoded is returned.
-
run_machine
(message)[source]¶ Runs through each character and encodes/decodes it. :param message: The user provided message.
Returns: The outout of encoding/decoding the message.
-
set_rotors
(slow, medium, fast)[source]¶ Sets the Rotors to use from User Input.
Parameters: - slow – This is the leftmost rotor,the rotor that steps the least.
- medium – This is the middle rotor,the rotor that double steps.
- fast – This is the rightmost rotor, steps for every character.
Returns: No return value,updates internal reference of chosen rotor.
Raises: ValueError
– The passed in rotor string is not a valid integer
-
set_rotors_intial_position
(user_input)[source]¶ Sets the Rotors starting position.
Parameters: user_input – The User Provided string of the rotors start position. Returns: No return values,updates the internal reference of the rotors position.
-
set_up
()[source]¶ Set up the machine according to user provided values.
Returns: The user provided message.
-
Rotor Dic¶
sadasdasdasd:
rotor_choices = {
1: {
'wiring': 'EKMFLGDQVZNTOWYHXUSPAIBRCJ',
'step': 'Q'
},
2: {
'wiring': 'AJDKSIRUXBLHWTMCQGZNPYFVOE',
'step': 'E'
},
3: {
'wiring': 'BDFHJLCPRTXVZNYEIWGAKMUSQO',
'step': 'V'
},
4: {
'wiring': 'ESOVPZJAYQUIRHXLNFTGKDCMWB',
'step': 'J'
},
5: {
'wiring': 'VZBRGITYUPSDNHLXAWMJQOFECK',
'step': 'Z'
},
}
Reflector Dict¶
These are the entries:
{
'reflector_b': 'YRUHQSLDPXNGOKMIEBFZCWVJAT', # b reflector
'reflector_c': 'FVPJIAOYEDRZXWGCTKUQSBNMHL' # c reflector
}