This is a simple project to emulate the ๐ก Enigma Machine ๐ use Python 3
The Enigma machine is an encryption device developed and used in the early- to mid-20th century to protect commercial, diplomatic and military communication. It was employed extensively by Nazi Germany during World War II, in all branches of the German military.
---- by Wikipedia
python3 enigma.py
By Alessandro Nassiri - Museo della Scienza e della Tecnologia "Leonardo da Vinci", CC BY-SA 4.0, Link
Press any key and the character change color in the light-board (on real model, it's all the blub ๐ก with characters) which is the encryt ๐ก result
on top of the board is roto, in the real Enigma machine, there only one number show out of the box, but I tried to make it's look like a ring :3
above of the light-board is Plug board, but if you don't plug anything, There're just input keyboard here. Don't worry about the message, you don't need plug to use this Enigma machine ๐
...
The plugboard contributed more cryptographic strength than an extra rotor.
...
A cable placed onto the plugboard connected letters in pairs; for example, E and Q might be a steckered pair. The effect was to swap those letters before and after the main rotor scrambling unit. For example, when an operator pressed E, the signal was diverted to Q before entering the rotors. Up to 13 steckered pairs might be used at one time, although only 10 were normally used.
---- by Wikipedia
The rotors (alternatively wheels or drums, Walzen in German) form the heart of an Enigma machine.
---- by Wikipedia
so if you've read the article in Wikipedia you should see that the roto have diffrent way to show up their value, diffrence by models. But all of them can be set up.
To setup in the real model, I think you gonna want to shift it by hand โ. In this Enigma Machine all you need to do is enter the value which the shift times of each rings. Notice that the rotos in this python model show vertically from top to bottom โฌ (in the real model it horizontally, from left to right โก๏ธ ).
The mechanical parts act by forming a varying electrical circuit. When a key is pressed, one or more rotors rotate on the spindle. On the sides of the rotors are a series of electrical contacts that, after rotation, line up with contacts on the other rotors or fixed wiring on either end of the spindle. When the rotors are properly aligned, each key on the keyboard is connected to a unique electrical pathway through the series of contacts and internal wiring.
---- by Wikipedia
So that custom wiring is the things that in fact soilders never do ๐ฟ. Because it's built in randomly and depends on what model of the Enigma Machine. Howerver I want to make it a little more interesting, so I add this function.
Basically, when you press A in the keyboard, the wiring lead you to another port of next roto (for example in Z port of the next, and the Z port go to the E for example and so on). So the setting gonna be "Z..." and "...E" because Z gonna be next cypher infomation for the A and E gonna be next cypher infomation for the Z. For example with this setting:
LUSHQOXDMZNAIKFREPCYBWVGTJ
a given machine configuration will encoded A to L, B to U, C to S, ..., and Z to J.
By default, the wiring of this Enigma Machine is the wiring of Commercial ๐ฐ Enigma which I think the simplest. You can take a look of details about roto for better explain and Roto wiring tables ๐ for another model's wiring.
A codebook is a type of document used for gathering and storing cryptography codes. Originally codebooks were often literally books, but today codebook is a byword for the complete record of a series of codes, regardless of physical format. by Wikipedia
so if you want to set up your enigma machine like a soilder, take a look at this page of codebook
Date | Ignore | Rings settings | Plug board settings | Ignore too |
---|---|---|---|---|
Date of the month ๐ For each day, we have diffrent settings |
we don't have this setting ๐
cuz we just have 3 rotos |
The shifting value of rings by order |
With a pair of characters, it's mean you should plug ๐ them together. In this machine, you just need to type all one by one. |
๐ |
Hope you have fun with it! โค๏ธ