Python3 replica of the enigma M4 "Shark" machine.
This project is completed. The outputs of this enigma simulator match those of other online simulators.
Prerequisites: python 3
.
After downloading the code:
-
Go in
enigma/main.py
and create a configuration object with the following structure, editing the values in < angular brackets >:configuration = { "rotors": { "rot1": {"rotor": rotors[<range I - VIII, string>], "starting_pos": <range 1-26 (int), or a-z (string)>, "ringstellung": <range 1-26 (int), or a-z (string)>}, "rot2": {"rotor": rotors[<range I - VIII, string>], "starting_pos": <range 1-26 (int), or a-z (string)>, "ringstellung": <range 1-26 (int), or a-z (string)>}, "rot3": {"rotor": rotors[<range I - VIII, string>], "starting_pos": <range 1-26 (int), or a-z (string)>, "ringstellung": <range 1-26 (int), or a-z (string)>}, "zus": {"rotor": zusatzwalze[<"gamma" or "beta">], "starting_pos": <range 1-26 (int), or a-z (string)>, "ringstellung": <range 1-26 (int), or a-z (string)>} }, "reflector": reflectors[<"UKW-B-thin" or "UKW-C-thin">], "plugboard": [<max 10 couples of letters, as string>] }
-
Create an instance of enigma and pass the configuration object as the first parameter and the text you want to encode as the second parameter, e.g.:
myEnigma = Enigma(configuration)
; -
Run the simulation and print the result, e.g.:
print(myEnigma.run("your text here"))
; -
Run the python file (by running
python3 main.py
) and you will see the output of the encryption in your terminal.
The entire project was realized using python3 only, without the use of any additional framework or library.
Sources used to learn about Enigma:
Simulator used to test the output: cryptii.com.