Skip to content

vanviethieuanh/enigma-machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Enigma Machine

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

Use

Required

python3 enigma.py

Explain

Enigma (crittografia) - Museo scienza e tecnologia Milano.jpg
By Alessandro Nassiri - Museo della Scienza e della Tecnologia "Leonardo da Vinci", CC BY-SA 4.0, Link

1. Use 😎

use

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

rotos

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 πŸ˜™

2. Plug board πŸ”Œ

...

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

3. Ring settings πŸ‘Œ

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 ➑️ ).

4. Custom roto wiring πŸ”€

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.

5. Codebook πŸ“–

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 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! ❀️

Releases

No releases published

Packages

 
 
 

Languages