The first Enigma machine was discovered by Arthur Scherbius, German engineer who acquired the patent in 1918. Name of this device originated from Greek word - riddle. It was used commercially from the early 1920s, and was also adopted by the military and governmental services of a number of nations — most famously German Army. Communication during those days was sent over radio which means that everyone could easily listen. But at that moment no one could spy on Nazi messages - Scherbius' Enigma provided them with the strongest cryptographic cipher of the world.
Since 1926 English cryptanalysts were eavesdropping German radio messages, unfortunately without being able to extract their meaning. But Polish officials, afraid of German attack started working on analyzing and breaking the cipher in office called Cipher Bureau (Biuro Szyfrów). By 1933 Marian Rejewski, Henryk Zygalski and Jerzy Różycki broke Enigma, by exploiting a fatal flaw of how Enigma operators sent their messages, and were able to determine the daily keys of almost every message that was intercepted.
From left: Jerzy Różycki, Henryk Zygalski and Marian Rejewski
They even developed a machine called the Bombe (Bomba), that made the process of codebreaking much faster. But back then keys were changing only once every few months, while during the war keys were changing at least once a day. In July 1939, just before the start of war Poles decided to inform the British and French about their research, also asking for help.
At Bletchley Park Alan Turing, together with fellow code-breaker Gordon Welchman invented different version of Bombe. When an Enigma message was intercepted, codebreakers had to search for so-called cribs, which were presumed pieces of plain text within the encrypted message. That way Turing Bombe would search for the enigma settings for a given piece of plain and cipher text. Although the British bombe actually owes little to the Bomba, Poles contributed a lot by supplying the internal wiring of the Enigma's rotors. They also demonstrated that Enigma can be broked using another machine. It has been estimated that the efforts of Turing and his fellow code-breakers shortened the war by several years. What is certain is that they saved countless lives and helped to determine the course and outcome of the conflict.
But let's head back from the history to something more technical.
Firstly, let's find out how Enigma has worked.
When sender sends the message, Enigma creates an electrical signal that goes through the wiring of the machine. First step for this signal is plugboard which attempts to get around frequency analysis. Some of the letters on the plugboard would be wired to other letters (plugs). Signal going through one of these plugs change original input into different letter, but also leaving some of the original letters unmoved.
View on the plugboard
The next step is the static rotor, which simply turns wires into static contacts, making the signal pass only when the contacts touch. But after that, things are getting a little bit more complicated. There are 5 rotors, with the possibility to choose 3 of them, for three positions - left, middle and right. Each rotor has their own set of inner, and outer rings of contacts. The outer ring contacts connect to the next rotor, together with its own inner ring. Purpose of these rings is to even more scramble the signal, resulting in more letter substitutions.
Rotor electrical view
In addition, as each letter is entered, the rotors rotate by one position, so that the same letters are never connected together in the same message. And even more, each rotor has notches in different positions which, when reached, cause the next rotor to its left to step forward too.
Last step that electrical signal takes before going back to the light board is the reflector. In Enigma machine there are 2 possible reflectors, each wired differently and producing different letter when reflected back. Journey back through the rotors works exactly the same way in reverse. Signal remains the same when passing through the static rotor, then going through the plugboard on the same principles. After that, signal goes to lightboard, where the light, corresponding for each letter, lits up.
But how would you decrypt the message?
To decode your message, you would need to know what rotor and plugboard settings were used during encryption. This was possible with use of monthly sheets, containing basic settings for every day of the month. They were in the custody of an officer, responsible for setting up the machine rotors and ringsettings. After setup, he could lock the machine front panel with a key. The operator of Enigma could only select the rotor start position.
Example of Wehrmacht Enigma key sheet
Mathematical Security of Enigma
Now, how secure is Enigma? Let's count all of the possibilities.
Enigma has 5 rotors, from which 3 are used.
Then all 3 rotors have 26 positions, one for each letter of the alphabet.
Quite a large number, right? Yet, we have to calculate all possibilities with the plug board.
And lastly, multiply them all together. This gives us quite a lot of combinations.
Enigma, was without doubt machine with great encryption capabilities. This war could have last much longer, or even end completely different, without hard work of great cryptanalytic minds working together on this operation.
 Singh Simon (2000) The Code Book: The Science of Secrecy from Ancient Egypt to Quantum Cryptography
 Rejewski Marian (1981) How the Polish Mathematicians Broke the Enigma. Annals of the History of Computing.