ADFGX cipher
Run the World War I ADFGX cipher, which turns each letter into a pair of the labels A, D, F, G and X and then shuffles the columns: under the keys NAVAL and CARGO, ATTACKATONCE comes out as DAFFAAXFXDXDDAFGAGAGDAXD. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Text
- ATTACKATONCE
- Square key
- NAVAL
- Key
- CARGO
- Calculation mode
- Encrypt
- Result
- DAFFAAXFXDXDDAFGAGAGDAXD
- Length
- 24
- Letters mapped
- 12
- Fractionated length
- 24
This ADFGX cipher tool encrypts or decrypts text using the classical German World War I scheme that combines a keyed 5×5 Polybius square with a second-stage columnar transposition. You supply a message, a square keyword that fills the Polybius grid, a transposition key that orders the columns, and an optional mode. On encrypt each Latin letter maps to a digraph of the labels A, D, F, G, and X; those symbols are then rearranged under the transposition keyword. Decrypt undoes the column order first and then maps digraphs back through the same square so a known pair of keys restores the original letters. I and J share one cell, non-letters are skipped on encrypt, and only ADFGX symbols are read on decrypt, matching common textbook and CTF conventions.
What the ADFGX cipher is and what this tool returns
ADFGX is a classical field cipher that fractionates each letter through a 5×5 Polybius square whose rows and columns are labelled with the Morse-friendly letters A, D, F, G, and X instead of digits one through five. The square is keyed: unique letters from the square keyword are written first in order of appearance, then the remaining alphabet fills the rest of the grid, with I and J forced into a single shared cell so twenty-five slots cover A–Z.
Encryption replaces every Latin letter with the two-label digraph of its row and column, producing a stream made only of ADFGX symbols whose length is twice the letter count. That stream is then written row-wise into a grid whose width equals the transposition key length and read column by column in the order obtained by sorting the key characters, with left-to-right index breaking ties when letters repeat.
Decryption reverses the layout using the same column heights derived from total length and key width, then pairs the recovered digraph stream and looks each pair up in the square. This page always applies that fixed contract and never silently switches to ADFGVX, Bifid, pure Polybius, or a transposition-only cipher.
Where ADFGX helps in class and in puzzles
Developers and educators meet the ADFGX cipher in capture-the-flag warm-ups, textbook chapters on World War I field cryptography, and demos that show why fractionation plus transposition raised the bar over simple substitution even though the scheme is not secure against modern cryptanalysis. Frontend teams can scramble sample phrases for screenshots without inventing a custom alphabet, then recover them with decrypt under the same square and transposition keys.
Backend services encode short challenge strings for puzzle APIs or teaching sandboxes where students must rebuild the square and grid to unlock the next step. Quality engineers generate deterministic encrypt and decrypt pairs for contract tests so a middleware that claims ADFGX support cannot silently switch to Bifid fractionation, drop the transposition stage, or force digit labels instead of A D F G X. Contest organizers precompute answer keys for modest English phrases without trusting opaque web toys that force uppercase-only output or insert padding characters you never asked for.
Product and education tools use the transform when a learner pastes ciphertext and the UI must show the recovered plaintext under the documented keywords. Pair it with other classical encoding helpers when you are building a small lab of free, deterministic text tools, and never treat ADFGX as a substitute for modern authenticated encryption such as AES-GCM for real secrets.
What you can do with it
CTF and classical cipher practice
Encrypt and decrypt ADFGX messages with square and transposition keywords for puzzles, classrooms, and capture-the-flag warm-ups.
History-of-crypto lessons
Demonstrate WWI ADFGX fractionation with A/D/F/G/X labels, I/J combining, and columnar transposition without forced padding.
FAQ
What does the ADFGX cipher tool cost?
It is free in your browser on this page.
How do I decrypt an ADFGX ciphertext?
Encryption is the default when mode is omitted.
How is ADFGX different from plain Polybius or columnar transposition?
ADFGX fractionates letters into A/D/F/G/X digraphs with a keyed square, then applies a second keyword columnar transposition. Plain Polybius stops after digit (or label) pairs; plain columnar only rearranges characters without fractionation.
Is ADFGX secure for real secrets?
No. It is a classical teaching cipher from World War I. Use modern authenticated encryption such as AES-GCM for real confidentiality.
Why do I and J share a cell in the ADFGX square?
Because a 5×5 square has only twenty-five slots for twenty-six letters. I and J are placed in one shared cell so the grid covers the whole alphabet, which means a J you encrypt comes back as I when you decrypt.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/enc/adfgx \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"ATTACKATONCE","square_key":"NAVAL","key":"CARGO"}'const res = await fetch("https://api.kit.forhosting.com/enc/adfgx", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"text": "ATTACKATONCE",
"square_key": "NAVAL",
"key": "CARGO"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/enc/adfgx",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"text": "ATTACKATONCE",
"square_key": "NAVAL",
"key": "CARGO"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/enc/adfgx", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"text":"ATTACKATONCE","square_key":"NAVAL","key":"CARGO"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"text":"ATTACKATONCE","square_key":"NAVAL","key":"CARGO"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/enc/adfgx", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"text": "ATTACKATONCE",
"square_key": "NAVAL",
"key": "CARGO"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "enc.adfgx",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Use it free in the browser for history-of-crypto lessons, puzzle design, and reversible lab demos, or call the API at $0.002 per successful request when pipelines need reproducible ADFGX transforms without re-implementing fractionation and grid packing yourself.
What the ADFGX cipher is and what this tool returns
The JSON response includes result for the ciphertext or recovered plaintext, mode set to encrypt or decrypt, square_key and key echoing the keywords you supplied, letters_mapped and fractionated_length for the digraph stage, key_length and column_order for the transposition stage, alphabet as the twenty-five-letter fill of the square, labels fixed to ADFGX, cipher fixed to adfgx, and a formula string that restates the two-stage contract for documentation and tests. There is no streaming path and no silent fallback to Vigenère or modern AES: either you supply text plus both keys under the documented rules, or the request fails with invalid_input. If you need only a plain Polybius digit map, only columnar rearrangement, or authenticated modern encryption, use those dedicated endpoints; this landing answers the combined ADFGX workflow that crypto history chapters and CTF warm-ups already describe.
How text, square_key, key, and mode are read and how results stay reproducible
Column order is computed once from the transposition key, and the same heights formula is used on encrypt and decrypt so a round trip always restores the original letters for any message that contains Latin letters under those two keywords. The preferred payload fields are text for the message, square_key for the Polybius keyword, key for the transposition keyword, and optional mode for encrypt or decrypt. Text accepts aliases such as input, value, s, message, plaintext, and ciphertext so forms and SDK clients can reuse existing column names without renaming every call site. Square_key accepts square_keyword, polybius_key, and square; it must contain at least one Latin letter after case folding, otherwise the engine raises invalid_input with a clear empty square_key message. Key accepts transposition_key, keyword, k, password, and passphrase; the entire non-empty string defines the columns, including digits and symbols if you include them, because ordering uses character comparison with Latin letters sorted case-insensitively and stable left-index ties on repeats. An empty transposition key is rejected with invalid_input. Mode defaults to encrypt when omitted and also accepts short aliases such as enc, encode, e for encrypt and dec, decode, d for decrypt; any other string fails validation. Missing text, missing keys, non-string types, letter-free encrypt plaintext, ciphertext with no ADFGX symbols, and odd digraph streams after the transposition undo all raise invalid_input so a blank form does not look like a successful no-op. Pair the free browser run on this page with the priced API when you need the identical ADFGX transform inside an automated pipeline without re-implementing digraph fractionation yourself. Invalid inputs return invalid_input and are not charged, which keeps validation cheap while successful transforms remain a fixed item price of $0.002.
Where ADFGX fits in lessons, puzzles, and test fixtures
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the ciphertext.
Integration use cases
Deterministic CI fixtures
Generate reproducible ADFGX ciphertext and plaintext pairs for unit tests, golden files, and contract checks.
Technical questions
What happens if square_key is empty?
The request fails with invalid_input. The Polybius square keyword must contain at least one Latin letter A–Z so the engine can fill a 5×5 grid.