 # How Long Would It Take You To Crack The Enigma Machine

By now almost everyone would have heard of the Enigma Machine, be it from your love for Benedict Cumberbatch, who played Alan Turing in the Imitation Game, or maybe you have a passion for code breaking.

Now I myself am a big fan of Cumberbatch and watching him in the Imitation Game led me to wonder, how long would it have taken me to crack the enigma machine?

First we need to understand what we’re up against, I’ll go through how the machine functioned.

If you pressed a letter on the keyboard it would send an electrical signal through the plugboard to the rotors, this would cause the rightmost rotor to shift once. The signal would then flow through the three rotors, bounce back off of the reflector, through the rotors and plugboard once again and light up a lamp on the board. Easy right?

## How does the machine work?

Let’s break it down, the first obstacle we face is the plugboard. This has 10 wires which connect 20 letters into pairs, two letters in a pair will swap over when input into the machine.

The next items we face are the three rotors. When this machine was being used in the army they had five rotors to choose from, each of these rotors is wired in a completely different way. It took some espionage to figure out the way in which the rotors were wired, but essentially each rotor takes the letter that has been input into the machine and switches it to a different one a certain number of places down the alphabet. Once this has been done the rotor shifts down one place, once the first rotor completes a full turn this triggers the next one to shift and so on.

## So how many combinations do we need to try?

Let’s do the math!! We can figure out how many settings on the Enigma Machine you would have to try to crack the code…

First, we need to place the rotors into the machine. We have five to choose from and the order in which we pick them matters. For the first rotor space we have five to choose from, for the second space we have four to choose from and for the third space we have three rotors to choose from. So overall there are $5\times 4\times 3 = 60$ ways to put the rotors into the machine.

Now each of these rotors can be put in 26 different ways, correlating to the 26 different letters of the alphabet. So we get $26\times 26\times 26 = 17,576$ different starting positions for the three rotors.

Finally we have the Plugboard, mathematically this is the most complex to explain so bare with me. We have ten wires to connect, each with two ends. So, the amount of plugs available decreases every time you plug one end in. There are 26 ways of plugging the first end in and 25 left for the other end. So there are $26\times 25$ ways of plugging this in, but then we are counting each combination twice as it doesn’t matter which end we plug in first, so we have to divide this by two. This gives us $\frac{26\times 25}{2} = 325$ different ways to plug the first wire in.

This process then repeats for the other nine wires. For the second wire we have 24 plugs for one end, 23 for the other divide this by two and we get $\frac{24\times 23}{2} = 276$. We continue this process until we get to the tenth wire which will have $\frac{8\times 7}{2}$ ways of plugging it in. This gives us $\frac{26\times 25}{2} \times \frac{24\times 23}{2} \times \frac{22\times 21}{2} \times … \times \frac{8\times 7}{2}$.

Unlike the rotors, it doesn’t matter the order in which the wires are plugged in. At the moment we have accounted for it so we need to divide by the amount of choices we had for each wire. We had ten choices for the first pair to plug in, nine choices for the next pair, and so on, down to one pair for the last. So we’ve actually repeated ourselves $10 \times 9\times 8 \times … \times 2 \times 1$  times. This can be written as $10!$ (10 factorial). For a more in depth explanation of this, see Georgia’s article “How Unique Is A Pack Of Cards?”. We then divide the previous calculation by $10!$ to get $$\frac{\frac{26\times 25}{2} \times \frac{24\times 23}{2} \times \frac{22\times 21}{2} \times … \times \frac{8\times 7}{2}} {10!} = 150,738,274,937,250.$$

To find the total number of settings we multiply the three figures together to get…

$$60 \times 17,576 \times 150,738,274,937,250 = 158,962,555,217,826,360,000.$$

Now that’s a big number, but it’s hard to put into perspective just how big it really is.

If you tried a different setting every second it would take you approximately 5,040,669,559,165 years. Which, I think we can agree is not exactly feasible. Even if we took the entire population of the world, which is around 7.8 billion, and we asked them to all try a combination of the enigma machine every second, it would still take 646 years to try every single possible combination!