Tool to decrypt/encrypt with ADFGVX, a German cipher from World War 1 using a grid and the letters A,D,F,G,V,X.
ADFGVX Cipher - dCode
Tag(s) : Substitution Cipher, Transposition Cipher, Grid Cipher
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
ADFGVX is a German military cipher dating from the First World War. It combines substitution using a 6Ă—6 grid with columnar transposition. The letters A, D, F, G, V and X are used to represent the coordinates of characters in the grid.
The ADFGVX cipher uses a 6Ă—6 square grid containing 36 distinct alphanumeric characters: the 26 letters of the Latin alphabet and the 10 digits from 0 to 9. The grid can be scrambled using a keyword.
The rows and columns are labelled, from top to bottom and from left to right, with the letters A, D, F, G, V and X. Each character is therefore identified by a pair of coordinates (row, column).
Example: A default ADFGVX grid (without a keyword), such that A = (A,A), Z = (V,D), etc.
| \ | A | D | F | G | V | X |
|---|---|---|---|---|---|---|
| A | A | B | C | D | E | F |
| D | G | H | I | J | K | L |
| F | M | N | O | P | Q | R |
| G | S | T | U | V | W | X |
| V | Y | Z | 0 | 1 | 2 | 3 |
| X | 4 | 5 | 6 | 7 | 8 | 9 |
Perform a substitution by bigrams, replacing each character in the message with its corresponding pair of coordinates.
Example: BERLIN becomes AD,AV,FX,DX,DF,FD
The intermediate message is then subjected to columnar transposition. This transposition uses a permutation key, usually derived from a keyword. To determine the column reading order, sort the letters of the keyword alphabetically.
Identical letters are ranked according to their order of appearance. However, avoiding repeated letters in the key is recommended, as they can make the permutation order more difficult to determine.
Example: The keyword CODE gives the permutation 1,3,4,2: the letters C(1),O(2),D(3),E(4), sorted alphabetically, become C(1),D(3),E(4),O(2), corresponding to columns 1,3,4,2.
Write the intermediate message row by row in a table whose width equals the length of the key.
If the number of characters does not fill the last row, some variants add padding characters, such as X. This padding is not mandatory and must be taken into account during decryption.
Example:
| C(1) | O(2) | D(3) | E(4) |
|---|---|---|---|
| A | D | A | V |
| F | X | D | X |
| D | F | F | D |
Rearrange the columns according to the order defined by the key.
Example: After transposition 1,3,4,2 (the 2nd column O(2) is moved to the end)
| C(1) | D(3) | E(4) | O(2) |
|---|---|---|---|
| A | A | V | D |
| F | D | X | X |
| D | F | D | F |
The final ciphertext is obtained by reading the columns from top to bottom, from left to right.
Example: The final ciphertext is AFDADFVXDDXF
Historically, encrypted messages were transmitted by radio, often in Morse code.
Decryption of the ADFGVX cipher requires the substitution grid and the transposition key.
Example: The plaintext DCODE, using the grid below and the transposition keyword CLE, produces the ciphertext FVFFVFAADA.
The keyword CLE defines the permutation 1,3,2, because the letters C(1),L(2),E(3), sorted alphabetically, become C(1),E(3),L(2).
The ciphertext is distributed vertically across a table with $ n $ columns, where $ n $ is the length of the key. The columns are initially considered in alphabetical order of the key, taking the length of each column into account.
Example:
| C(1) | E(3) | L(2) |
|---|---|---|
| F | V | F |
| F | V | F |
| A | A | D |
| A |
If the last row was not padded during encryption, take the actual number of characters in each column into account.
Restore the columns to their original order, as determined by the positions of the letters in the keyword.
Example:
| C(1) | L(2) | E(3) |
|---|---|---|
| F | V | F |
| F | A | D |
| A | V | F |
| A |
Then read the table row by row to recover the intermediate message before transposition.
Example: FAVVDFFAAF
Split this message into bigrams and replace each pair with the character corresponding to its coordinates (row, column) in the substitution grid.
Example:
| \ | A | D | F | G | V | X |
|---|---|---|---|---|---|---|
| A | A | Z | E | R | T | Y |
| D | U | I | O | P | Q | S |
| F | D | F | G | H | J | K |
| G | L | M | W | X | C | V |
| V | B | N | 0 | 1 | 2 | 3 |
| X | 4 | 5 | 6 | 7 | 8 | 9 |
Example: FA = row F, column A = D; VV = C; DF = O; FA = D; AF = E. The plaintext is DCODE.
An ADFGVX ciphertext normally contains only the six letters A, D, F, G, V and X.
The ciphertext length is generally even because each plaintext character is first replaced with a bigram.
If padding characters are added before transposition, the length of the intermediate text may also depend on the key length.
The name Painvin is generally associated with ADFGVX.
Clues relating to the First World War (WWI) should be noted.
The Roitelet Theorem is a novel by Frédéric Cathala (https://www.amazon.com/gp/product/2226153918?tag=dcodefr-21). Its plot features a spy during the First World War who encounters messages encrypted with ADFGVX.
Without transposition, the text obtained after substitution consists of bigrams that directly represent the plaintext characters. Columnar transposition separates the two letters of these bigrams and scrambles their order.
Frequency analysis, message length and repeated patterns can provide clues, but they do not always establish with certainty whether transposition was used.
The column permutation can be searched for without knowing the original key by testing different column orders. A brute-force attack quickly becomes expensive as the number of columns increases. Use the Brute-force Permutations button when this feature is available.
It may be possible to recover some or all of the substitution grid after reconstructing the intermediate text and its bigrams. This can be approached as a substitution problem by exploiting frequency patterns and likely plaintext structures. dCode's monoalphabetic substitution tool may help explore some hypotheses, but adapting the analysis to bigrams is necessary.
Decrypting ADFGVX without either the transposition key or the substitution grid is a more complex cryptanalytic task. One approach is to search for the column permutation first, then attempt to reconstruct the grid from the resulting bigrams. Success depends in part on the message length, the plaintext language and the available clues.
The letters A, D, F, G, V and X were chosen because their Morse code representations are sufficiently distinct to reduce the risk of confusion during radio transmission.
The ADFGVX cipher was used by the German Army from June 1918. It was an evolution of the ADFGX cipher, introduced in March 1918. Adding the letter V made it possible to use a 6Ă—6 grid containing the 26 letters of the Latin alphabet and the 10 digits.
GEDEFU 18 is an abbreviation of the German phrase « GEheimschrift DEr FUnker 18 », which can be translated as « radio operators' cipher 18 ». The name is associated with the ADFGVX cipher system.
ADFGX is a German military cipher introduced in March 1918 and the predecessor of ADFGVX. It uses a 5Ă—5 grid based on the Polybius square and the five letters A, D, F, G and X to represent character coordinates. The letter J is generally omitted from the grid to accommodate the remaining 25 letters.
The breaking of the ADFGVX cipher is particularly associated with French cryptanalyst Georges-Jean Painvin. One of the messages he deciphered became famous as the « Radiogram of Victory ». The intelligence obtained helped the French anticipate a German offensive in the Compiègne sector in June 1918.
Georges-Jean Painvin succeeded in deciphering messages encrypted with ADFGX and ADFGVX during the spring of 1918. On 2 June 1918, he deciphered the message that became famous as the « Radiogram of Victory ».
dCode retains ownership of the "ADFGVX Cipher" source code. Any algorithm for the "ADFGVX Cipher" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "ADFGVX Cipher" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "ADFGVX Cipher" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "ADFGVX Cipher" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: ADFGVX Cipher on dCode.fr [online website], retrieved on 2026-11-28,