Enigma Machine

To begin, set your rotors and start typing! Mobile users: Type in the input box.


Rotor 1
Rotor 2
Rotor 3

Code:
Input:

                       

Lights

Q
W
E
R
T
Y
U
I
O
P
A
S
D
F
G
H
J
K
L
Z
X
C
V
B
N
M

Buttons

Q
W
E
R
T
Y
U
I
O
P
A
S
D
F
G
H
J
K
L
Z
X
C
V
B
N
M

Static Wheel
{{position.position}}- {{position.flow}}: {{position.letter}}
Rotor1
{{index}}- ltr: {{item.letter}} con: {{item.connection}} {{item.flow}}
Rotor2
{{index}}- ltr: {{item.letter}} con: {{item.connection}} {{item.flow}}
Rotor3
{{index}}- ltr: {{item.letter}} con: {{item.connection}} {{item.flow}}
Reflector
{{item.input}} <-> {{item.output}}

Using the machine is simple.

If someone sends you a code:

Make sure Rotors 1, 2, and 3 match your friend's starting position, and then start typing the code EXACTLY as you received it. You can either use the keyboard or click the buttons on the page. The lights will light-up, but it is easier to just look in the code box to see the message. Spaces and special characters are not allowed, you'll have to figure it out without them. You must type the message exactly as it was received. If you make a mistake, you have to start over due to how the Enigma machine works.

To send someone a secret code:

Choose a letter for Rotor 1, 2, and 3. Make a note of the letters you've chosen before starting. Then just start typing. Your message will be coded in the Code box, or you can look at the lightbulbs as they light-up. Then, send that secret code to your friend (and the original positions for the rotors). Remember, no backspacing allowed! It won't work due to the complexity of the Enigma machine. If you make a mistake, you must start over.

If you saw Benedict Cumberbatch star in The Imitation Game, you might remember he was a playing Alan Turing, a code-breaker in World War 2. The code he was trying to break was particularly difficult, Nazi Germany was using Enigma Machines to communicate in secret. Even though the Allies could easily grab the messages being sent back and forth, the messages were completely garbled and indecipherable. You had to have an Enigma machine and know how to set it up to decode them.

Enigma (crittografia) - Museo scienza e tecnologia Milano

Enigma machines weren't only used by the Nazis, they were used by anyone who wanted to keep their communication secret, but they are most famous as being a tool of the German Military in World War 2. Alan Turing and his team famously broke the Germans' Enigma code during World War 2. You can watch the movie for more or read The Book. (I haven't read it, but the movie was good).

Step by Step

Step 1: You press a button

Easy enough, you just press a button, just like if you were using a typewriter. Let's say you pressed "Q".

Step 2: Pressing the button completes a circuit

As you press a button, a circuit within the machine is completed. We will now follow the electricity through the machine.

Step 3: Start at the static wheel

The electricity starts at a piece called the "static wheel", which will take the letter you've pressed, and find the wire to start on.

Step 4: Move Across the Rotors

From the wire at the "static wheel" the electricity moves to a "rotor". A rotor is a basically a wheel of scrambled wires. For example, if you pushed the letter "Q", the static wheel sends the electricity to rotor 1, which maps "Q" to wire 23. Rotor 2 maps position 23 to wire 5, and Rotor 3 maps wire 5 to wire 17. So now we are at position 17 at the end of Rotor 3.

Step 5: Reflect

After the third rotor, we have reached "the reflector", another wire scrambler thing, but this one differs from the rotors in that it doesn't move. Let's say Rotor 3's postion 17 touches "the reflector's" position 17. That gets mapped to position 3, and we are ready to go back through the rotors.

Step 6: Back through the rotors

We move back through the rotors just the same way as earlier, but this time backwards, and starting from position 3. Let's say that maps to Rotor 2's position 6, Rotor 1's position 1 and now static wheel position 1.

Step 7: Light up a lightbulb

We are at position 1 of the static wheel. Let's say that is connected to "Lightbulb A". Perfect, "Lightbulb A" will light up. You write down "A". To recap: you pushed button "Q", and lightbulb "A" lit-up.

You might think you're done at this point. "Q" and "A" go together, right? Not so fast. This would be too easy. After each time you push a button, the rotors spin, rescrambling the wires within the machine. So if you push "Q" again, a different letter will light up.

Like a Mirror

You can think of the Enigma Machine like a mirror. In our example, "Q" and "A" were mirrored together. The next time you press a button, the mirror will have changed. The person decoding the message will have the same "mirror" as long as their rotors start in the same position. They will press "A", and "Q" will light up for them.


Numberphile, an excellent YouTube channel goes into detail with a real Enigma Machine here. I highly recommend it if you are interested. Louise Dade's website has an excellent diagram as well, here.

The software version on this web page is my attempt at a replica. Overall, it is implemented the same way as a real machine. My machine is incompatible with other Enigmas on the web, as my rotors are custom, and the logic is totally unique to this web page. My machine also lacks a plug-board, which could be a cool addition someday.

If you want to see it in action, check the "Debug Mode" box. It will show you the "guts" of the machine, including the wires and reflector that are active with each button-press. If you want to learn more, look through the enigma.js JavaScript file, or just ask me. This was a really fun project, though it pushed the limits of my brain power. I truly have no idea how Alan Turing and the other code-breakers at Bletchley Park were smart enough to build a machine to decode these things, and I have a lot of respect for them.