ADFGVX cipher: WWI method and converter
The ADFGVX cipher is a German field cipher from the First World War. Each of its steps on its own is easy to break, but together they are much harder. It is named after the six letters that the encrypted message is made of: A, D, F, G, V and X. First, every letter is replaced with a pair of coordinates in a square, much as in the Polybius square. Then these pairs are shuffled according to a keyword, a little like in the rail fence cipher.
Step one: a 6 × 6 square
The Polybius square has only 25 cells and there is no room in it for digits. ADFGVX uses a 6 × 6 square, that is 6 · 6 = 36 cells: exactly enough for the whole English alphabet (26 letters) and ten digits. That is why you find Q and W in it too, which Czech hardly needs. The rows and columns carry not the numbers 1 to 6 but the letters A, D, F, G, V, X.
The sender and the receiver first agree on a key that shuffles the square. Let’s take OHNIŠTĚ (Czech for “fire pit”). Without accents we are left with OHNISTE, and we write these seven letters in row by row. If a letter appeared twice in the key, we would write it only the first time. Then we continue with the alphabet, leaving out the letters already in the square (E, H, I, N, O, S, T). The last two rows are filled by the digits 0 to 9:
| A | D | F | G | V | X | |
|---|---|---|---|---|---|---|
| A | O | H | N | I | S | T |
| D | E | A | B | C | D | F |
| F | G | J | K | L | M | P |
| G | Q | R | U | V | W | X |
| V | Y | Z | 0 | 1 | 2 | 3 |
| X | 4 | 5 | 6 | 7 | 8 | 9 |
We will encrypt “sraz v 9 u mostu” (Czech for “meet by the bridge at 9”), without spaces SRAZV9UMOSTU. For each letter we write first the letter of its row, then of its column. S lies in row A and column V, so it becomes AV. R is GD, A is DD, Z is VD and so on up to the last U, which gives GF:
S R A Z V 9 U M O S T U
AV GD DD VD GG XX GF FV AA AV AX GF
That is not very secret yet. Every S is still AV, so it is an ordinary substitution, and frequency analysis cracks that. So the second step comes next.
Step two: shuffling by a keyword
The second key is another word, say PRAMEN (Czech for “spring”). We write all 24 letters row by row under the key, six to a row. Above the columns we write the position of each letter of the key in the alphabet: A is first, E second, M third, N fourth, P fifth and R sixth. If a letter repeats in the key, such as the two As in KANADA, the one standing further left gets the lower number. The converter counts it the same way.
We read the columns from top to bottom in the order of the numbers. Under A is GGFA, under E DXAG, under M DGVX, under N DXAF, under P AVGA and under R VDFV. Altogether GGFADXAGDGVXDXAFAVGAVDFV. Telegraph operators sent the cipher in groups of five, so we send
GGFAD XAGDG VXDXA FAVGA VDFV
The shuffle has broken the pairs apart. From the first AV (the letter S), the A ended up in the fifth group of four and the V in the sixth.
How to decrypt an ADFGVX cipher
The receiver goes backwards. They divide the number of letters by the length of the key (here
A catch arises when the number of letters is not a multiple of the key length. The last row is then incomplete, and the longer columns are those standing furthest left under the key, that is, first in the order in which the key is written, not by the alphabet. Take 10 letters under the key STAN. The remainder of
ADFGVX cipher converter
Type in a message and both keys. The converter drops spaces, punctuation and Czech accents, keeps digits, and outputs the cipher in lower case in groups of five. When decrypting it looks only at the letters A, D, F, G, V, X, but it cannot restore the spaces between words. The key of the square may also contain digits, while in the key of the shuffle only letters are counted.
Why A, D, F, G, V, X?
The messages were sent by radio in Morse code, and in it these letters have codes that are easy to tell apart: A is ·−, D −··, F ··−·, G −−·, V ···− and X −··−. According to the usual explanation they were chosen so that the radio operator would be as unlikely as possible to make a mistake through the noise. And if N (−·) were heard in place of A, the result would be a pair that is not in the square at all.
Why it is stronger than a plain substitution
With the square alone, a codebreaker would count pairs. The most common pair would belong to the most common letter, say E, and they would track down the rest as with a substitution cipher. But the shuffle tears the pairs apart: the first and second letters end up in different columns and far apart in the cipher. Until the codebreaker guesses the order of the columns, there is nothing to count. And to guess the order they would need to recognise meaningful pairs, but the square hides those from them. One step covers the other.
Compared with the Playfair cipher, ADFGVX has one more advantage. It encrypts digits too, so you don’t have to spell out the time or coordinates in words.
How Painvin broke it anyway
The cipher was designed by the German lieutenant Fritz Nebel. From March 1918 the Germans used the ADFGX version with a 5 × 5 square; at the turn of May and June the letter V and the 6 × 6 square were added. The keys changed every day. The French codebreaker Georges Painvin nevertheless broke a message intercepted on 1 June as early as 2 June. His method relied on the fact that on one day many messages went out with the same keys and some began similarly. From such messages he worked out the shuffling of the columns, and what remained was an ordinary substitution of pairs, for which frequency analysis is enough. The message asked for faster deliveries of ammunition, it came from German positions near the village of Remaugies, and the French command moved its reserves on the strength of it. Historians disagree on how much this affected the course of the German offensive.
ADFGVX at camp
- Print out the square from the table above for each group. The key of the square can be, for example, OHNIŠTĚ or KOTLÍK (Czech for “billycan”).
- For a game a message of 8 to 15 letters is enough; longer ones take a long time to encrypt by hand and mistakes add up.
- Give younger children only step one, that is, the square without the shuffle.
- Don’t use the word “transposition” with children; talk about shuffling. A short key is enough for the shuffle: STAN (Czech for “tent”), PRAMEN, VODNÍK (Czech for “water sprite”).
- Put the finished cipher into the converter, switch to Decrypt and check that your message comes out.
You can give the codebreakers just one key. Whoever knows the square but not the second word shuffles the columns until pairs come out that make sense. For a short message it makes a nice puzzle for a whole afternoon.