ADFGVX
ADFGVX
A 6×6 grid of letters and digits.
- Keyspace
- 36! grids × n! column orders
- Decode
- same options back
- Works on
- A-Z and 0-9, the rest dropped
- Family
- 10 in fractionation
Options
Access
- Create
create("adfgvx") - CLI
ciphers encode adfgvx 'ATTACK AT 1200' - Tryplayground with the sample above
- Kinpolybius, nihilist, morse, fractionated-morse +5
The German field cipher of 1918 had two steps. First a 6×6 substitution that turns every letter or digit into a pair from ADFGVX, six letters picked because they sound nothing alike in Morse. Then a columnar transposition with a second key. The grid holds A to Z and 0 to 9, key reorders it with the keyword first, duplicates removed. transposition is the second key: the pairs are written in rows under it and read out column by column in its alphabetical order, the same rule as columnar. Anything that isn't a letter or a digit is dropped.
const adfgvx = create("adfgvx");
const keys = { key: "147 regiment", transposition: "privacy" };
adfgvx.encode("attack at 1200am", keys).text; // "DXXVGDADDAAXDVDXVFGVGFADDVVD"
adfgvx.decode("DXXV GDAD DAAX DVDX VFGV GFAD DVVD", keys).text; // "ATTACKAT1200AM"
adfgvx.encode("ATTACK AT 1200").text; // "AAGDGDAAAFDVAAGDVGVVVFVF"
adfgvx.decode("AAGDG"); // CipherError: Invalid ADFGVX code: 5 letters A, D, F, G, V and X, not whole pairs
Leave transposition out and you get the grid step alone, which is half a cipher: fine for a puzzle that only uses the grid, useless against a real 1918 message. Decoding drops everything but the six letters before undoing the columns, so the five-letter groups of a telegram go in as printed. Every letter or digit is a pair, so an odd count means one went missing on the way. Decoding says so instead of handing back a shorter message. Text with none of the six letters is an error too, not an empty answer.