Introduction
The ADFGX cipher is a WWI German field cipher invented by Lieutenant Fritz Nebel of the German Army and used from March 1918. It is the predecessor of the ADFGVX cipher and combines two stages: a 5x5 Polybius square substitution that fractionates each letter into a pair of the symbols A, D, F, G, X, followed by a columnar transposition keyed by a second word. The five symbols were chosen because they are easily distinguished in Morse code. French cryptanalyst Georges Painvin broke the cipher in June 1918 by analyzing columns of intercepted messages that shared transposition keys. This tool encrypts and decrypts with the ADFGX cipher using your own Polybius and transposition keys.
What this tool does
- Encrypts plain text using the two-stage ADFGX cipher (Polybius substitution + columnar transposition).
- Decrypts ADFGX ciphertext back to plain text.
- Uses a keyword-derived 5x5 Polybius square with I and J merged.
- Supports custom Polybius and transposition keys.
- Runs entirely in your browser with no server-side processing.
How this tool works
Enter a Polybius key (used to build the 5x5 square) and a transposition key. In encode mode, type plain text and the tool first replaces each letter with its Polybius coordinate pair from the ADFGX alphabet, then writes the resulting symbol stream into rows under the transposition key and reads the columns in alphabetical key order. In decode mode, paste ADFGX ciphertext and the tool reverses the transposition, then defractionates each symbol pair back to a letter using the same Polybius square. The output updates instantly as you type or change keys.
How the ADFGX cipher works
The ADFGX cipher's first stage is a Polybius substitution. A 5x5 grid is filled with the 25 letters of the alphabet (I and J share a cell) using a keyword: the keyword's unique letters go first, then the remaining alphabet letters. Each cell is indexed by a row and column label from the set A, D, F, G, X. For example, with the keyword GERMAN, the letter G might be at row A, column D, producing the pair AD. Each plaintext letter becomes two ADFGX symbols, doubling the message length. The second stage is a columnar transposition. The fractionated symbol stream is written into rows under the letters of a second keyword. The columns are then read out in alphabetical order of the key letters, scrambling the symbol pairs so that adjacent Polybius coordinates no longer correspond to the same plaintext letter. Painvin broke the cipher by finding messages with identical transposition keys (detected by matching message lengths and patterns) and aligning their columns. When enough messages shared a key, the column permutations could be reconstructed, undoing the transposition and exposing the underlying Polybius substitution to frequency analysis. The ADFGVX cipher, introduced later in 1918, added a sixth symbol V and a 6x6 grid to include digits.
How to use this tool
- Enter a Polybius key (e.g. GERMAN) to build the 5x5 substitution square.
- Enter a transposition key (e.g. ARMY) for the columnar transposition.
- Select Encode or Decode.
- Type or paste text into the input field.
- Read the result in the output field, which updates live.
Real-world examples
Encrypting a short message
Polybius key: GERMAN, transposition key: ARMY. Input: `ATTACK`. The Polybius stage fractionates each letter into an ADFGX pair, then the transposition rearranges the pairs into the final ciphertext.
Decrypting with the same keys
Polybius key: GERMAN, transposition key: ARMY. Input: the ADFGX ciphertext from the previous example. Output: `ATTACK`. The tool reverses the transposition, then defractionates each symbol pair.
Why five symbols
The symbols A, D, F, G, X were chosen because their Morse codes (.-, -.., ..-., --., -..-) are easily distinguished even under poor radio conditions. This made the cipher practical for field use over telegraph.
Comparison with similar methods
| Method | Complexity | Typical use |
|---|---|---|
| ADFGX | O(n) — substitution + transposition | WWI German field cipher (1918) |
| ADFGVX | O(n) — 6x6 substitution + transposition | WWI German field cipher (later 1918) |
| Playfair | O(n) — digraph substitution | WWI British field cipher |
| Two-Square | O(n) — digraph substitution | Simplified Playfair variant |
Limitations or considerations
This tool implements the standard ADFGX cipher with a 5x5 Polybius square (I/J merged) and a columnar transposition. The real German military used daily-changing keys and sometimes additional conventions like nulls or fixed-length message formats. Painvin's attack required multiple messages with the same transposition key; a single short message with a unique key is harder to break in practice. The tool does not implement the ADFGVX variant (6x6 grid with digits).
Frequently asked questions
What is the difference between ADFGX and ADFGVX?
ADFGX uses a 5x5 Polybius square with the five symbols A, D, F, G, X and covers 25 letters (I/J merged). ADFGVX, introduced later in 1918, adds a sixth symbol V and uses a 6x6 grid that also encodes the digits 0-9.
Who broke the ADFGX cipher?
Georges Painvin of the French Bureau de Chiffre broke it in June 1918. He exploited the fact that many German messages shared the same daily transposition key, allowing him to align columns and reverse the transposition before attacking the Polybius substitution.
Why were the symbols A, D, F, G, X chosen?
Their Morse codes are easily distinguished even under poor radio conditions. A is dot-dash, D is dash-dot-dot, F is dot-dot-dash-dot, G is dash-dash-dot, X is dash-dot-dot-dash. This reduced transcription errors in field telegraphy.
Is ADFGX secure today?
No. With modern computational cryptanalysis, ADFGX can be broken quickly, especially when multiple messages share a transposition key. It is a historical cipher, not a practical one.
Conclusion
The ADFGX cipher tool lets you encrypt and decrypt with the WWI German field cipher that combines a keyword Polybius square and a columnar transposition. It supports custom keys for both stages and demonstrates the fractionation technique that made ADFGX a significant advance over simpler substitution ciphers, until Painvin's analysis showed how shared keys could undo it.