Skip main navigation

Hurry, only 10 days left to get one year of Unlimited learning for £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

Counting the number of possible settings

How many ways were there of setting up the internal workings of the Enigma machine? We can use our knowledge of permutation counting to work this out.
Someone using a calculator
© University of York

The difficulty in reading Enigma-encrypted messages came not just from the machine itself but mainly from the manifold different ways of setting the machine up. Without knowing the daily settings, it would appear impossible to read the messages.

The codebook settings

Each unit in the German military had a codebook that gave the day’s settings for the Enigma machine. Anyone with the codebook and an Enigma machine would be able to both send and decrypt messages with anyone else in the same unit. All the units used the same type of Enigma machine, and they all used the same set of radio nets to broadcast their messages on, but they had their own daily settings. This means an Army operator couldn’t read a message sent by the Airforce, for example, unless that operator also had the codebook used by the Airforce.

In order to inform the user who was sending a message – and so which settings to use to decrypt it – a three letter discriminant was sent in the clear (i.e. unencrypted) at the start of the message.

Gordan Welchman tells an amusing story in his book The Hut Six Story. The British initially didn’t know what unit used a particular discriminant, so they colour-coded each message according to its discriminant, as they knew all messages of the same colour would use the same settings that day. The two colours with the most messages were Red and Blue, each with over 250 messages per day. When they were able to break the codes, they realised that Blue was in fact a training camp for new recruits! However Red was genuine messages, mainly between the Army and Airforce.

The daily settings

  • Rotor order. Which rotors to use, and which order they should be placed in the Enigma machine.
  • Ground setting. This consisted of three letters. For each rotor, the top letter was visible in the Enigma machine. The operator would move the rotors until these three letters were topmost. This part of the daily key settings was changed to a different system after 1938, but for the moment we will concentrate on the way things were set-up during 1938.
  • Plugboard connections. Before the War started, this consisted of six pairs of letters, and informed the user which pairs of letters to switch in the plugboard. In later years, the plugboard had ten pairs of letters switched, leaving only six letters unpaired.

The number of possible settings

A few years before the War started, there were only three rotors, but they could be put in the machine in any order, which gives 6 rotor choices.

Later (from 15th Dec 1938), the number of available rotors increased to five, giving (5 times 4 times 3 = 60) possible rotor choices. In the end stages of World War 2, eight rotors were available (although the machine still only had space to use any three of them at any one time), making (8 times 7 times 6 = 336) choices for the rotors.

(The U-boats had a four-rotor Enigma machine, with a choice of eight rotors, giving a total of (8 times 7 times 6 times 5 = 1680) options.)

Each rotor can be set to start on any letter, so the number of possible Ground Settings equals (26^3 = 17,576).

So just considering the rotors and their starting positions, there were (6 times 26^3 = 105,456) possible starting positions. It was the plugboard that was the source of the combinatorial complexity of the Enigma machine.

In 1938 – the period of time we’re concentrating on – the plugboard switched six pairs of letters, leaving fourteen letters unchanged. The number of ways of doing this is

[begin{split} &frac{1}{6!}left( frac{26 times 25}{2}right) times left( frac{24 times 23}{2}right) times left( frac{22 times21}{2}right) \ & qquad timesleft( frac{20 times19}{2}right) timesleft( frac{18 times17}{2} right) timesleft( frac{16 times15}{2}right) \ & = frac{1}{6!} frac{26!}{14!} frac{1}{2^6 } approx 10^{11}. end{split}]

To see why this is the correct number, note that the first wire has 26 choices for one end, 25 choices for the other end. But switching letter A with B is the same as switching letter B with A, hence we need to divide this number by 2. Similarly the second wire has 24 remaining choices for its first end and 23 for its second end, again dividing by 2 to avoid double-counting. Repeat this down to the sixth wire. The remaining factor of (frac{1}{6!}) comes from the fact that the order of the wires doesn’t matter.

In later years the plugboard had ten pairs of letters switched, leaving only six letters unchanged. The number of such possibilities equals

[frac{26!}{10! 6! 2^{10} } approx 1.5times 10^{14}.]

Therefore the total number of initial positions for an Engima machine in early 1938 equals

[frac{6 times 26! times 26^3 }{ 2^6 6! 14!} approx 1.06 times 10^{16}.]

It would be impossible to try all possible settings by brute force. But, as we shall soon see, mathematics saved the day!

© University of York
This article is from the free online

The Mathematics of Cryptography: From Ancient Rome to a Quantum Future

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now