The Enigma was used by the Germans during the second world war to encrypt and decrypt messages.
The machine consists of three parts:
The keyboard,
the lampboard
and the rotors.
Before we look at how the machine works, let's take a look at how the machine was operated first.
Let's assume the operator wants to encrypt the word enigma.
He would now press the letter E on the keyboard.
Underneath every letter of the lampboard  a small lightbulb was installed.
When the operator pressed a key, an electric current would flow from the key via the rotors to one of the lightbulbs.
In our case the letter H would light up.
This letter is the first letter of the encrypted message.
This is a simplified model of the Enigma.
On the left side we have the keys from the keyboard.
In our example we have only four letter A B C D.
On the right side we have the lamps from the lampbord.
Without the rotors every key is connected to one specific lamp.
So if you press the key A,
lamp A will light up.
Now we are adding the first rotor.
The rotor has contacts on two sides, that are connected by wire.
If the wires would go straight through the rotor,
pressing key A would still light up lightbulb A.
If the contacts of the rotor are not connected with the directly opposing side,
then key A is not connected to the same light any more.
Every time a key is pressed, the rotor will move one step further.
So the next time key A is  pressed, a new light will light up.
After four turns the rotor would be back in his starting position.
In the real Enigma, that used 26 letters,
the rotor would need 26 steps.
The second rotor is of the same type as the first one.
If you position rotor 2 behind rotor 1,
the current will flow through of the both rotors,
before it reaches the lightbulb.
Unlike rotor one, that turns every time a key is pressed,
rotor two only moves forward, after rotor one has made one full turn.
The German Enigmas had three or sometimes four of these rotors,
that would be lined up one after the other.
Apart from the rotors the Enigma had a reflector
or Umkehrwalze.
Unlike the rotors, the reflector had only contacts on one side,
which were connected to each other.
So the reflector would send the signal back.
This assembly made it possible to encrypt and decrypt a text with the same machine.
For example, if you pressed A, light B  would light up.
If you would keep the rotors in the same position,
pressing key  B
would now  lead to light A.
So if the receiver of a message knew the position of the rotors of the sender's enigma,
he could simply decrypt the message by typing the text into his own enigma.
As handy as this assembly might have been,
it had a major flaw.
Whenever you press key A,
you automatically cut off light A from the circuit.
That means, whenever you press key A,
light A will never glow up.
This helped the allies to break the code of the enigma,
because whenever they found an A in an encrypted text,
they knew that there could not be an  A in this place in the original text.
