The ADFGVX Cipher
Learn about ADFGVX, the German WWI field cipher that combined Polybius-square fractionation with columnar transposition. It was considered so strong that French cryptanalyst Georges Painvin needed weeks to break a message that helped stop a 1918 offensive.
Interactive ADFGVX Cipher Visualizer
🔐 ADFGVX Cipher Visualizer
The ADFGVX Cipher: Fractionation Meets Transposition
Introduction
By 1918, the German military needed a field cipher that could be encoded and decoded quickly by soldiers using only Morse-code-friendly letters. It also had to resist the frequency analysis that had already broken simpler ciphers. Their answer, ADFGVX, combined two techniques already covered in this series, Polybius-style fractionation and columnar transposition, into a single two-stage cipher. It’s the direct, practical descendant of the Bifid cipher’s fractionation idea, engineered into a real wartime tool. It was tough enough that French cryptanalyst Georges Painvin needed weeks of dedicated work to break a single intercepted message. The effort was so exhausting it reportedly cost him significant weight (traditionally cited as around 15 kilograms, though the exact figure is folklore; the exhaustion itself is well-attested). That work ultimately helped Allied forces anticipate a major German offensive.
Table of Contents
- Why Only Six Letters?
- How the ADFGVX Cipher Works
- Stage 1: Building the Square
- Stage 2: Columnar Transposition
- A Worked Example
- Decryption
- Why Combining Fractionation and Transposition Works So Well
- Pros and Cons Analysis
- How ADFGVX Was Actually Broken
- Modern Relevance
- Python Implementation
- Limitations
- Conclusion
- FAQ
- References
Why Only Six Letters?
ADFGVX’s name comes from the only six letters its ciphertext ever uses: A, D, F, G, V, X. This wasn’t arbitrary. These letters were specifically chosen because their Morse code representations are all quite distinct from one another (unlike, say, E and I, whose Morse codes are easily confused). That distinctness drastically reduced transmission errors over noisy wartime radio and telegraph lines. An earlier, closely related version called ADFGX used only five letters and a 5×5 grid, like a standard Polybius square. ADFGVX extended this to six letters and a 6×6 grid, specifically to fit both the full alphabet and the ten digits into a single grid.
How the ADFGVX Cipher Works
ADFGVX runs in two distinct stages, exactly mirroring the two cipher families covered earlier in this series:
- Fractionate every character of the plaintext into a pair of ADFGVX letters, using a 6×6 keyed grid. This is precisely the same idea as the Polybius square, just with 36 cells (A-Z plus 0-9) instead of 25, and letter labels (A,D,F,G,V,X) instead of number labels.
- Transpose the resulting stream of ADFGVX letters using columnar transposition with a second, independent keyword.
Interactive Visualizer
Try it above with the defaults: Square Keyword “PRIVACY” and Transposition Keyword “ZEBRA”. Watch Stage 1 fractionate each character into an ADFGVX pair, then watch Stage 2 scramble that intermediate stream using the same columnar transposition process covered earlier in this series.
Stage 1: Building the Square
The 6×6 grid is built exactly like a keyed Polybius square, following one general rule: write the keyword’s unique letters first, then the remaining letters of the alphabet in order, then the digits 0-9. The rows and columns are labeled A, D, F, G, V, X instead of 1 through 6.
Here’s an example square built from the keyword “PRIVACY”:
A D F G V X
A P R I V A C
D Y B D E F G
F H J K L M N
G O Q S T U W
V X Z 0 1 2 3
X 4 5 6 7 8 9
Following the general rule above: “PRIVACY” contributes its 7 unique letters first, then the remaining unused letters A-Z fill in, then the digits 0-9 fill the last 10 cells.
Each plaintext character is replaced by its row letter followed by its column letter. H sits at row F, column A, so it becomes “FA”. Spaces and punctuation are conventionally stripped from the message before fractionation begins, exactly as with the other grid-based ciphers in this series. Only letters and digits occupy cells in the square.
Stage 2: Columnar Transposition
The fractionated stream from Stage 1, a string made entirely of A, D, F, G, V, and X, is then written into a grid under a second keyword and read back out column by column. This works in exactly the same way covered in the columnar transposition cipher guide: columns are read in the order determined by sorting the transposition keyword’s letters alphabetically.
A Worked Example
Using Square Keyword “PRIVACY” and Transposition Keyword “ZEBRA”, encrypt “HELLO”:
Stage 1 (fractionation): Looking up each letter in the square above:
| Letter | H | E | L | L | O |
|---|---|---|---|---|---|
| Pair | FA | DG | FG | FG | GA |
Concatenated: “FADGFGFGGA” (10 ADFGVX letters)
Stage 2 (transposition): Writing “FADGFGFGGA” into a 5-column grid under “ZEBRA” and reading columns in alphabetical order (A,B,E,R,Z → columns 5,3,2,4,1):
Z E B R A
F A D G F
G F G G A
Reading column 5 (A): F,A → “FA”. Column 3 (B): D,G → “DG”. Column 2 (E): A,F → “AF”. Column 4 (R): G,G → “GG”. Column 1 (Z): F,G → “FG”.
“HELLO” → “FADGAFGGFG”
Decryption
Decryption reverses both stages, in reverse order:
- Undo the transposition: using the transposition keyword, split the ciphertext back into columns of the correct lengths, place them in the grid according to the reading order, and read the grid back out row by row. This recovers the Stage 1 intermediate stream (“FADGFGFGGA”).
- Undo the fractionation: split the recovered stream into pairs of ADFGVX letters, and look each pair up in the square (row letter, then column letter) to recover the original plaintext character.
Applying this to “FADGAFGGFG” with the same two keywords recovers “HELLO” exactly. Concretely, the first pair of the recovered stream is “FA”: row F, column A in the square above is H, the first letter of “HELLO,” exactly as expected.
Why Combining Fractionation and Transposition Works So Well
Each stage defends against a different kind of attack, and together they cover each other’s weaknesses:
- Fractionation alone (like a keyed Polybius square or Bifid) scrambles letter identity. But a plain fractionated stream, before transposition, still has each ciphertext-letter-pair’s position tied directly to one plaintext character’s position. That leaves exploitable structure.
- Transposition alone (like columnar transposition) scrambles letter position. But it leaves each letter’s identity completely unchanged, so simple letter-frequency analysis still works perfectly on a transposition-only ciphertext.
By fractionating first and then transposing the fractionated stream, ADFGVX ensures that transposition scrambles fragments (row letters and column letters) that individually don’t correspond to complete plaintext characters. An attacker can’t simply “unscramble the transposition” and immediately read plaintext, the way they could against transposition alone. This layered defense is precisely the same principle later formalized as confusion and diffusion in modern cipher design.
Pros and Cons Analysis
| Advantages | Disadvantages |
|---|---|
| Two Independent Layers of Defense: Combines fractionation (defeats simple substitution attacks) with transposition (defeats simple frequency analysis on the raw fractionated stream) | Two Keys to Manage: Requires securely distributing and remembering both a square keyword and a transposition keyword |
| Handles Letters and Digits: The 36-cell grid accommodates the full alphabet plus numerals, unlike 25-cell ciphers that must merge I/J | Genuinely Complex to Perform by Hand: Two full stages of manual work, each with its own bookkeeping, made it slow and error-prone for field use |
| Morse-Code-Friendly Output: The six chosen letters have maximally distinct Morse representations, minimizing transmission errors | Vulnerable with Enough Traffic Volume: As covered below, real-world cryptanalysis (Painvin’s work) succeeded by exploiting patterns across many intercepted messages, not just one |
| Historically Significant: A genuine wartime-grade cipher, respected enough that breaking it was treated as a major Allied intelligence achievement | No Real-World Security Today: Like every cipher in this series, offers no protection against modern computational cryptanalysis |
How ADFGVX Was Actually Broken
Georges Painvin’s success against ADFGVX didn’t come from a single mathematical shortcut. It came from painstaking statistical analysis across many intercepted messages, exploiting the fact that:
- Messages sharing the same transposition key produce fractionated streams with related column structures. These can be compared and cross-referenced across multiple intercepts to infer the transposition pattern.
- Once the transposition is undone, the recovered ADFGVX stream is subject to the same kind of frequency-and-pattern analysis that breaks fractionated ciphers like Bifid. With enough volume of traffic, the underlying square can eventually be reconstructed.
- Operational discipline mattered enormously: reused keys, predictable message formats, and high message volume during the German 1918 offensive gave Painvin the statistical leverage he needed. A cipher used disciplined, with fresh keys and low volume, would have been considerably harder to break even with period techniques.
- Stereotyped message openings gave Painvin a concrete foothold: German military traffic, like most wartime signal traffic, tended to reuse similar phrasing at the start of messages (routine headers, standard reporting formats). Messages sharing the same daily key that also began with similar stereotyped openings produced fractionated streams with correspondingly similar structure near their start. That was exactly the kind of cross-message pattern his statistical comparisons could exploit, without needing to guess the exact plaintext of any single message in isolation.
This is a recurring theme across this entire series: even a well-designed cipher can be undermined by real-world usage patterns, independent of the underlying mathematics.
Modern Relevance
ADFGVX secures nothing today, but its historical and educational significance is substantial:
- A landmark in cryptographic history: one of the most famous field ciphers ever broken, and a textbook case study in applied wartime cryptanalysis.
- A clean, concrete illustration of layered cipher design: combining two different technique families (fractionation and transposition) to cover each other’s individual weaknesses, foreshadowing the confusion-and-diffusion principle at the heart of modern block ciphers like AES.
- A natural capstone to this series’ progression through classic ciphers: starting from single-operation substitution (Caesar), through polyalphabetic substitution (Vigenère, Beaufort, Autokey), through transposition (columnar), through fractionation (Polybius, Bifid), and finally combining transposition and fractionation together in one working historical cipher.
Python Implementation
The two stages are two independent functions. Stage 2 reuses exactly the same column-ranking logic from the columnar transposition cipher guide:
LABELS = 'ADFGVX'
ALPHANUM = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' # 36 cells: full alphabet + digits
def generate_square(key):
key = key.upper()
key = ''.join(c for c in key if c.isalnum())
square = []
seen = set()
for char in key + ALPHANUM:
if char not in seen:
seen.add(char)
square.append(char)
return square
def fractionate(text, square):
text = ''.join(c for c in text.upper() if c.isalnum())
result = ''
for char in text:
row, col = divmod(square.index(char), 6)
result += LABELS[row] + LABELS[col]
return result
def defractionate(stream, square):
result = ''
for i in range(0, len(stream), 2):
row = LABELS.index(stream[i])
col = LABELS.index(stream[i + 1])
result += square[row * 6 + col]
return result
def get_column_order(keyword):
return sorted(range(len(keyword)), key=lambda i: (keyword[i], i))
def columnar_encrypt(text, keyword):
cols = len(keyword)
column_order = get_column_order(keyword)
grid = ['' for _ in range(cols)]
for i, char in enumerate(text):
grid[i % cols] += char
return ''.join(grid[col] for col in column_order)
def columnar_decrypt(ciphertext, keyword):
cols = len(keyword)
rows, extra = divmod(len(ciphertext), cols)
column_order = get_column_order(keyword)
col_lengths = [rows + (1 if i < extra else 0) for i in range(cols)]
columns, index = [''] * cols, 0
for col in column_order:
length = col_lengths[col]
columns[col] = ciphertext[index:index + length]
index += length
result = ''
for row in range(rows + 1):
for col in range(cols):
if row < len(columns[col]):
result += columns[col][row]
return result
def adfgvx_encrypt(text, square_key, transposition_key):
square = generate_square(square_key)
fractionated = fractionate(text, square)
return columnar_encrypt(fractionated, transposition_key.upper())
def adfgvx_decrypt(ciphertext, square_key, transposition_key):
square = generate_square(square_key)
fractionated = columnar_decrypt(ciphertext, transposition_key.upper())
return defractionate(fractionated, square)
if __name__ == "__main__":
square_key = "PRIVACY"
transposition_key = "ZEBRA"
plaintext = "HELLO"
ciphertext = adfgvx_encrypt(plaintext, square_key, transposition_key)
recovered = adfgvx_decrypt(ciphertext, square_key, transposition_key)
print(f"Plaintext: {plaintext}")
print(f"Ciphertext: {ciphertext}")
print(f"Recovered: {recovered}")
This reproduces the worked example above exactly: HELLO → FADGAFGGFG → HELLO, with fractionate producing the same intermediate stream (FADGFGFGGA) shown in Stage 1 above before columnar_encrypt scrambles it in Stage 2.
Limitations
This implementation covers the mechanism, not the operational discipline that actually mattered historically:
- No period-based key management. As the Cryptanalysis section above explains, reused keys across high volumes of traffic are what actually let Painvin break ADFGVX. This code has no concept of key rotation or message volume limits.
- No support for ADFGX. The earlier five-letter, digits-free variant would need a 5×5 grid and only five labels; this code only implements the six-letter, alphanumeric version.
- No validation that both keys are non-empty. An empty transposition keyword breaks
columnar_encrypt’s modulo the same way it would in the standalone columnar transposition implementation. - Not intended for real security. As the Modern Relevance section notes, this was a genuinely strong wartime field cipher, but it offers no protection against modern computational cryptanalysis regardless of implementation quality.
Conclusion
ADFGVX represents the practical high-water mark of hand-cipher design covered in this series: a real, deployed wartime cipher that deliberately layered two distinct scrambling techniques to defend against two distinct classes of attack. It held up long enough to meaningfully affect military operations in 1918. Breaking it required Georges Painvin’s exceptional, sustained cryptanalytic effort rather than a quick trick. That is a testament to how far classical cryptography had progressed, by combining ideas that, individually, this series has already shown to be breakable on their own.
FAQ
What does “ADFGVX” mean?
It’s the name of the six letters (A, D, F, G, V, X) that the cipher’s intermediate and final ciphertext are built from. These letters were chosen because their Morse code representations are maximally distinct, reducing transmission errors.
How does ADFGVX combine fractionation and transposition?
It first fractionates each plaintext character into a pair of ADFGVX letters using a keyed 6×6 grid (like a Polybius square), then applies columnar transposition to the resulting stream of ADFGVX letters using a second, independent keyword.
What’s the difference between ADFGVX and ADFGX?
ADFGX is the earlier, five-letter version using a 5×5 grid (25 cells, letters only, I/J merged). ADFGVX extends this to six letters and a 6×6 grid (36 cells), adding room for the ten digits alongside the full alphabet.
Who broke the ADFGVX cipher, and how?
French cryptanalyst Georges Painvin broke it through weeks of painstaking statistical analysis across multiple intercepted messages. He exploited patterns in how the transposition and fractionation interacted across messages sharing the same keys, rather than relying on any single shortcut against one message alone.
Why is ADFGVX considered a landmark in cryptographic history?
Because it was a genuine, deployed field cipher whose cryptanalysis had real military consequences. Painvin’s work helped Allied forces anticipate a major German 1918 offensive, making it one of the most historically significant classical cipher breaks.
References
-
Wikipedia. “ADFGVX cipher.” Available at: https://en.wikipedia.org/wiki/ADFGVX_cipher
-
Kahn, David. “The Codebreakers: The Story of Secret Writing.” Macmillan, 1967.
-
Singh, Simon. “The Code Book.” Doubleday, 1999.
-
Practical Cryptography. “ADFGVX Cipher.” Available at: http://practicalcryptography.com/ciphers/adfgvx-cipher/