While on holiday after Christmas, and slightly deprived of things to do, I was saved by an interesting message from a friend – a game they had been playing had an easter egg, a code you had to break. It is no simple code.

The cipher (technically, there is a difference between ciphers and codes, but that’s not vital) is called an ADFGX cipher. It is a mixture of two different coding mechanisms – a fancy substitution cipher (letters are substituted for each other) and a transposition cipher (letters are shuffled around).

Firstly, you take the letters ADFGX (thus the name) and you draw up a polybius square(fancy table), something like this:


What I have done is to draw a square with ADFGX down both sides, then rearranged the 26 letters of the alphabet into the resulting square, in random order. You may notice there are only 25 squares to fit letters into – the letter ‘i’ is removed, and ‘j’ is used to replace it. To encode a sentence, such as:


you take each letter, and find its co-ordinates on the table, reading the left hand letter first. for example, ‘P’ becomes ‘AD’, as that is the co-ordinate on the table. ‘O’ becomes ‘AX’. Altogether, this becomes


this is the substitution part. Next, you get a cipher key, such as “friend”. you rearrange the letters of the ciphertext under this in rows, like this:





maybe with less awkward formatting. I use stars to indicate blanks. You rearrange the keyword in alphabetical order, taking the ciphertext column underneath with each letter:





you then remove the keyword, and read the message as columns:


and there is your cipher!

Cracking the cipher is much more difficult. The standard tools for cryptanalysis is frequency analysis – not all letters in the english language occur with the same frequency, some are more common. If you take a cipher, you might find that, for example, “q” is the most common. In normal English, “e” is the most common letter, followed by “t” and “a”. There is a good chance that “q” is the stand-in for “e”, or maybe “t”. This only works if you have a decent chunk of text to work with. However, the ADFGX cipher turns each letter into 2 letters, and splits them up, which makes this technique tricky to perform. But not impossible. Here are a few possible crutches that can be used to unravel the code.


If you analyze the text (towards the end of this piece), “F” is the most common by far, taking  around 43% of the letters. G is next, with 27%. X and D both take 11%, and A takes 8%. This tells you that, in the original table, letters in the F and G rows and columns (of which there are 16) are the most common. There is also a good chance that a lot of the F’s and G’s are combined, suggesting that one of FG or GF represents “e”, or maybe “t” or “a”.


When I created the keyword, I didn’t just pick any random word. I chose the word “friend” because it doesn’t have any repeating letters – If the letters repeated, then there would be more than 1 way of arranging the letters in alphabetical order to scramble the code. While it is possible for the keyword to have repeated letters, it is unlikely, for each repeated letter makes it exponentially harder to decrypt, even if you have all the keys – 1 double means 2 options to check, but 4 means 16 options, which is a bad idea. My guess is the keyword doesn’t repeat letters much, if at all.



This cipher was created as part of a game – therefore, it is reasonable to assume that the keyword might be related to the game (Mob of the dead).


The code comes in a specific format of 6×12. It is possible that this indicates the keyword is 12 letters long. To see why, remember that, when reading the ciphertext off the transposition key, you read the columns and turn them into rows. This means that the 12 rows in the ciphertext would have been 12 columns under 12 letters, which is the key’s length.

However, it is also possible it was formatted like that to throw people off the scent. There is another possible demonstration of the key being 12 letters long – at the end, there is a group with only 2 letters, and 4 spaces. If the code was scrambled with the columns present in the code, those spaces shouldn’t all be together – if scrambled in rows, it makes much more sense.


The actual letters of the key don’t matter – they aren’t included or involved in the final ciphertext. All that matters is the order they are in within the alphabet, as this determines how they are mixed up when sorted alphabetically. This means that, for example, instead of testing 25!/19! keys, or 127512000 keys if the key is 6 letters, we only need to try 6!, or 720. if the key is 12 letters, we get 479001600 keys, which is not great, but better than the alternative (2490952020000000)

This is an ongoing effort that we might never solve, but it’s fun to try.

The ciphertext from the game: