Skip to content

ADFGVX Cipher

Enter a square, a transposition keyword and a message to encode or decode it with the ADFGVX cipher, or its 5 × 5 predecessor ADFGX. The tool shows both stages: the Polybius square that turns each character into two letters, and the columnar transposition that scrambles them. Free, no sign-up, and nothing leaves your browser.

Mode

Its characters fill the square first, each used once; the rest of the alphabet (and the digits) follow. Type all 25 or 36 characters to set the square exactly.

Sets the order of the columns in the second stage. Equal letters are taken left to right. Use at least two letters or digits.

The square

Along the rows is the usual way. A real square was an arbitrary mixed alphabet, so a full 25- or 36-character keyword fixes it whichever way you choose.

Only letters (and digits, in the 6 × 6 square) are enciphered. Spaces and punctuation are dropped, and the result is in capitals. The cipher text uses only the letters A, D, F, G, X (and V).

Both stages

Stage 1 — the Polybius square

Each plain character becomes two letters: the label of its row, then the label of its column.

ADFGVX
ANA1C3H
D8TB2OM
FE5WRPD
G4F6G7I
V9J0KLQ
XSUVXYZ

Characters and their pairs

PlainATTACKAT1200AM
PairADDDDDADAGVGADDDAFDGVFVFADDX

Stage 2 — the columnar transposition

Write the pair letters in rows under the keyword. Number the columns in the alphabetical order of the keyword's letters (equal letters left to right) and read the columns off in that order, top to bottom.

PRIVACY
4536127
ADDDDDA
DAGVGAD
DDAFDGV
FVFADDX

The first row is the order the columns are read in. The last row may be short; it is not padded.

Pair letters in order: ADDDDDADAGVGADDDAFDGVFVFADDX

How to Use the ADFGVX Cipher Tool

  1. 1. Choose ADFGVX or ADFGX. ADFGVX uses a 6 × 6 square holding the letters and the digits 0–9. ADFGX uses a 5 × 5 square, where I and J share a cell or Q is left out.
  2. 2. Set the square. Type a keyword and the rest of the alphabet follows, or type all 25 or 36 characters to fix the square exactly, as the original mixed alphabets did.
  3. 3. Enter the transposition keyword. It sets the order in which the columns are read in the second stage. Use at least two letters or digits.
  4. 4. Type the message and choose Encode or Decode. Only letters and digits are enciphered. The working shows the square, each character's pair of letters and the transposition grid.

How the ADFGVX Cipher Works

ADFGVX is a two-stage cipher. In the first stage a Polybius square, with its rows and columns labelled A, D, F, G, V and X, turns each plain character into two letters: the label of its row, then the label of its column. This is fractionation, and it doubles the length of the message. In the second stage, the pair letters are written in rows under a transposition keyword. The columns are then read off in the alphabetical order of the keyword's letters, top to bottom, with equal letters taken left to right and the last row left short. The cipher text uses only those six letters.

Neither stage is strong alone. A plain Polybius substitution gives away the letter frequencies, and a plain transposition gives away the letters themselves. Together they scatter the pairs, so that a letter's two halves travel to different columns. To decode, you reverse the order: first undo the transposition by cutting the cipher text into columns of the right length, then read the rows as pairs and look each pair up in the square.

Worked Example

Wikipedia's ADFGVX example uses the square NA1C3H8TB2OME5WRPD4F6G7I9J0KLQSUVXYZ, typed in full as the keyword, and the transposition keyword PRIVACY. The message is attack at 1200am.

StageResult
Plain charactersA T T A C K A T 1 2 0 0 A M
Stage 1: pair lettersAD DD DD AD AG VG AD DD AF DG VF VF AD DX
Keyword column orderP R I V A C Y → 4 5 3 6 1 2 7 (read A, C, I, P, R, V, Y)
Stage 2: cipher textDGDD DAGD DGAF ADDF DADV DVFA ADVX

The first stage turns A into AD because A sits in row A, column D of the square. The 28 pair letters then fill four rows under PRIVACY, and reading the columns in the order A, C, I, P, R, V, Y gives the cipher text. The tool reproduces both lines, and ADFGX works the same way with a 5 × 5 square: Wikipedia's ADFGX example turns attack at once, with keyword CARGO, into FAXDF ADDDG DGFFF AFAXA FAFX.

History of the ADFGVX Cipher

ADFGVX was a field cipher of the Imperial German Army in the First World War, invented by Lieutenant Fritz Nebel. Its predecessor ADFGX was first used on 1 March 1918 on the Western Front, and ADFGVX followed on 1 June 1918 with the extra V and row and column so that digits could be sent. The letters were chosen because they sound very different in Morse code, which cut the errors of radio operators. Both the square and the transposition keyword changed every day.

How It Was Broken

The French cryptanalyst Georges Painvin broke the cipher in 1918. He worked from messages with stereotyped openings to find patterns in the transposition, and he exploited the fact that, when the keyword has an even length, the columns alternate between pair letters from the rows and from the columns of the square, which have different frequency profiles. French accounts credit his solutions with helping to stop the German Spring Offensive; historian Hilmar-Detlef Brückner disputes how decisive they were. Today a computer breaks ADFGVX from a modest amount of cipher text.

A historical cipher, not a secure one

ADFGVX was a serious cipher in 1918, but it is far from secure now. Use it for history, puzzles and teaching, never for anything private.

Frequently Asked Questions

What is the ADFGVX cipher?
ADFGVX is a hand cipher used by the German army in 1918. It substitutes each character with two letters taken from a 6 × 6 Polybius square, then scrambles the letters with a columnar transposition. The cipher text uses only the six letters A, D, F, G, V and X.
What is the difference between ADFGX and ADFGVX?
ADFGX came first, in March 1918, and used a 5 × 5 square with I and J sharing a cell. ADFGVX followed in June 1918 with a 6 × 6 square that holds all 26 letters and the digits 0–9, so numbers could be sent.
How do you decode an ADFGVX cipher?
First undo the transposition. Work out the column lengths from the keyword and the message length, cut the cipher text into those columns in the keyword's alphabetical order, and write them back into the grid. Then read the grid by rows to get pair letters and look each pair up in the Polybius square.
Why were the letters A, D, F, G, V and X used?
They look very different when sent in Morse code, which reduced mistakes by radio operators. The letters carry no meaning of their own, and any six distinct letters would give the same cipher.
Who broke the ADFGVX cipher?
The French lieutenant Georges Painvin broke it in 1918. He used stereotyped message beginnings and the different letter statistics of the row and column halves of each pair to recover the transposition and then the square.
Is the ADFGVX cipher secure?
No. It was strong for its time, but modern software recovers both keys from a modest amount of text. Treat it as a historical cipher for learning and puzzles.

Related Tools

More in Codes & Ciphers

See all Codes & Ciphers