Columnar Transposition Cipher

Write in rows, read columns by keyword alphabetical order - keyword permutation cipher.

Last reviewed: April 2026

New to this tool? Click here for instructions

Plaintext
Ciphertext
Enter plaintext and set a keyword.

Encrypt and decrypt with the classical columnar transposition cipher — write your plaintext into a grid under a keyword, then read out the columns in the order the keyword dictates. Every computation runs in your browser; no plaintext or key ever leaves your machine.

What This Tool Does

Columnar transposition is a classical cipher that rearranges plaintext letters according to a keyword-derived column order. The plaintext is written into a fixed-width grid one row at a time, with the keyword's letters labeling each column. To encrypt, the columns are read out in the order given by the keyword letters' alphabetical ranking — column whose label is A first, then B, then C, and so on. The output is a permutation of the original plaintext characters with the same letter-frequency profile but a scrambled position order.

This tool supports both directions. Encryption pads the last row with X when needed, derives the column read order, and emits the ciphertext in five-letter groups (the standard format for hand-written cryptograms). Decryption reverses the process: given the ciphertext and the keyword, the tool computes how many letters fall in each column, distributes the ciphertext across columns in the correct read order, then reads the grid row-wise to recover the plaintext. The step-by-step view renders the underlying grid with column rank numbers highlighted so you can trace the construction by eye.

Everything happens client-side. There is no server round-trip, no telemetry on your messages, and no logging of the keyword you pick. Close the tab and the state is gone.

How to Use It

Type a keyword into the keyword field at the top — any string of letters works, though 5 to 10 characters is the practical sweet spot. Choose Encrypt or Decrypt in the mode chips. Enter your text in the left pane and the result appears live in the right pane as you type. The status bar at the bottom confirms the active keyword, column count, and row count so you can verify the grid dimensions match what you expect.

Click Step-by-Step to reveal the grid view beneath the main panes. Each column header shows the keyword letter at the top and its derived read-order rank in green below, so you can see exactly which column is read first, second, third, and so on. The grid populates with the actual padded plaintext for the active encryption, with any pad characters added to fill the last row shown in muted italic.

The Try Example button loads the canonical demonstration message WE ARE DISCOVERED FLEE AT ONCE with key ZEBRA — the same example used in textbooks and in the worked walkthrough below. The Copy button copies the ciphertext exactly as displayed (five-letter groups for encryption, contiguous for decryption). Spaces and punctuation in the input are stripped automatically, and the parser is case-insensitive: zebra and ZEBRA produce the same key.

Worked Example: Encrypt WE ARE DISCOVERED FLEE AT ONCE with Key ZEBRA

This is the textbook example for columnar transposition and a quick way to sanity-check any implementation. Click Try Example to load it directly into the tool.

  1. Strip non-letters and uppercase. The input WE ARE DISCOVERED FLEE AT ONCE becomes WEAREDISCOVEREDFLEEATONCE — 25 letters.
  2. Derive column ranks from the keyword. ZEBRA has letters Z, E, B, R, A. Sorted alphabetically: A, B, E, R, Z. So A=1, B=2, E=3, R=4, Z=5. Mapped back to the original positions: Z=5, E=3, B=2, R=4, A=1. The column read order is therefore 5-3-2-4-1 (read column A first, then B, then E, then R, then Z last).
  3. Fill the grid row by row. Five columns means each row holds five letters: row 1 is W E A R E, row 2 is D I S C O, row 3 is V E R E D, row 4 is F L E E A, row 5 is T O N C E. With 25 letters in 5 columns the grid is exactly filled — no padding needed.
  4. Read columns in rank order. Column A (read order 1) holds positions 5, 10, 15, 20, 25 — that's E, O, D, A, E. Column B (read order 2) holds positions 3, 8, 13, 18, 23 — A, S, R, E, N. Column E (read order 3) holds positions 2, 7, 12, 17, 22 — E, I, E, L, O. Column R (read order 4) holds positions 4, 9, 14, 19, 24 — R, C, E, E, C. Column Z (read order 5) holds positions 1, 6, 11, 16, 21 — W, D, V, F, T.
  5. Concatenate to produce the ciphertext. Joining the columns in read order: EODAE ASREN EIELO RCEEC WDVFT. Compare against the tool output to confirm the implementation is correct.

The diagram below shows the same construction visually: plaintext written row by row into the grid, then columns extracted in the order ranked by the keyword letters.

Columnar transposition with key ZEBRA A 5-row by 5-column grid filled with plaintext letters, with arrows showing how columns are read in alphabetical key order to produce ciphertext. Plaintext grid (key ZEBRA, rows filled left-to-right) Ciphertext (columns read in rank order) Z E B R A 5 3 2 4 1 W E A R E D I S C O V E R E D F L E E A T O N C E column rank 1 (A): EODAE E O D A E column rank 2 (B): ASREN A S R E N column rank 3 (E): EIELO E I E L O column rank 4 (R): RCEEC R C E E C column rank 5 (Z): WDVFT W D V F T
Plaintext is filled left-to-right into the grid under the keyword ZEBRA. Each column is then extracted in the order given by the alphabetical rank shown in green (A=1, B=2, E=3, R=4, Z=5). Concatenating those five column reads produces the final ciphertext.

Common Use Cases

Historical cryptography education. Columnar transposition sits at a useful pedagogical sweet spot: complex enough to demonstrate genuine permutation (unlike monoalphabetic substitution), simple enough that students can encrypt and decrypt by hand in a single class period. It appears in every introductory cryptography textbook from Stinson's Cryptography: Theory and Practice to Singh's The Code Book, and instructors use it to motivate the eventual transition to product ciphers that combine substitution and permutation — exactly the structure modern AES inherits.

CTF and puzzle challenges. Capture-the-flag competitions regularly include transposition challenges in their crypto categories. The classic move is to obfuscate the keyword: hide it as a substring in another clue, derive it from a Caesar shift of another piece of text, or chain transposition with substitution to force solvers through multiple stages. Once you recognize the ciphertext has the same letter frequencies as English (suggesting transposition rather than substitution), columnar is one of the first hypotheses to test.

Puzzle and escape-room design. Game designers favor columnar transposition because it produces ciphertext that looks superficially encrypted but is solvable by hand within the time budget of a puzzle session. Combined with a thematic keyword tied to the puzzle's narrative, it rewards solvers for paying attention to story details while staying mechanically straightforward.

Understanding the classical-to-modern transition. Studying columnar transposition makes the design decisions inside AES easier to read. AES's ShiftRows step is itself a fixed-pattern row-level transposition; its MixColumns step is a linear mixing across columns. The fundamental insight that diffusion requires moving information between positions is exactly what transposition demonstrates — modern ciphers just iterate this insight many times with cryptographically chosen permutations rather than keyword-derived ones.

Edge Cases and Limitations

Irregular last row. When the plaintext length isn't a multiple of the key length, the final row has empty trailing cells. The two conventional fixes are pad characters (this tool uses X) and null columns (leaving the cells empty and recording per-column lengths separately). Padding is simpler but corrupts the plaintext's tail; nulls preserve the plaintext exactly but complicate decryption because the receiver must know which columns are short. This tool uses the padding convention to keep the encryption deterministic and the grid view rectangular.

Duplicate letters in the keyword. If the keyword contains repeated letters — say PIZZA — the alphabetical ranking has ties. The standard tie-break is left-to-right by original position: the first Z gets rank order 4 and the second Z gets rank order 5. The tool implements this rule consistently, so PIZZA, ZAPIZ, and similar keys with repeated letters produce predictable output.

Key length and security tradeoffs. Longer keys produce a larger keyspace (k! permutations for a k-letter key) but also create more columns, which means shorter individual columns. Very short columns are easier to attack by anagram solving because the per-column letter set is small. The historical sweet spot used by field cipher manuals sat between 7 and 12 characters — long enough to make brute force tedious by hand, short enough to keep columns substantive.

Double transposition for additional security. Applying columnar transposition twice with two different keywords meaningfully extends resistance to anagramming attacks. The columns from pass one are scrambled into new positions before pass two, destroying the per-column frequency signatures that single transposition leaks. Soviet diplomatic communications and World War II Allied agent codes both used double transposition extensively.

Anagram-based cryptanalysis on short messages. For ciphertexts under roughly 100 characters, the keyspace search and the anagram search converge quickly. A cryptanalyst tries each plausible key length (5 through 12), writes the ciphertext into that column count, then anagram-solves the rows by hand looking for valid English. This is fast enough that single columnar transposition on short messages is considered trivially broken even without a computer.

Key recovery via column-period detection. Even when the key is unknown, repeated common digrams in the plaintext (TH, HE, ER, AN) leave statistical traces. Cryptanalysts use the index of coincidence to detect the column period, then anagram the columns into recognizable text. The Friedman team formalized this attack against military transposition ciphers in the late 1930s.

Behind the History

Columnar transposition's recorded military use dates to the 1880s, when Russian nihilists adopted variations of it for revolutionary correspondence — keyword choices were typically poetic phrases that could be remembered without a written record, and the technique was deliberately chosen because it could be performed without specialized equipment. Decades later, this same accessibility made it attractive to wartime intelligence services that needed a cipher field agents could perform with pencil and paper alone.

The cipher's most famous deployment is the German ADFGX system, introduced in March 1918 and expanded to ADFGVX two months later. ADFGX combined a 5×5 Polybius substitution (letters chosen because their Morse code representations were maximally distinguishable over noisy telegraph lines) with a columnar transposition over the substituted output. The two-stage construction was significantly harder to break than either component alone — but French cryptanalyst Georges Painvin broke it in June 1918, partly by exploiting traffic from a single critical message known as the Radiogram of Victory. ADFGX is considered one of the most influential ciphers of World War I.

During World War II, Soviet diplomatic communications used double columnar transposition as one layer of their cipher stack. The VENONA project, a long-running American counterintelligence effort that decoded portions of intercepted Soviet traffic from 1942 onward, eventually exposed Soviet espionage in the Manhattan Project — though the breakthroughs came largely from one-time-pad key reuse rather than direct cryptanalysis of the transposition layer. The decryptions remained classified until 1995.

Systematic cryptanalysis of pure columnar transposition was formalized by the William Friedman team at the U.S. Army Signal Intelligence Service in the late 1930s. Their work on the index of coincidence and column-period detection turned what had been an artisanal codebreaking practice into a procedural method that could be taught and scaled, and it set the analytical foundations later used against ADFGX, Enigma, and beyond.

Cryptanalysis

Column-period detection via index of coincidence. The first step in attacking unknown columnar transposition is determining the key length. Write the ciphertext into candidate column counts (5, 6, 7, ... up to about 15), then compute the index of coincidence within each column. Natural English averages an IC of 0.067; uniform random text averages 0.038. When the candidate column count matches the true key length, each column's IC will sit near 0.067 because each column was filled with natural-language letters before transposition. Wrong widths produce a near-random IC distribution across columns.

Anagram solving for short blocks. Once the column count is identified, the columns are known up to permutation. For short ciphertexts (under 200 characters), the analyst writes each row across all columns and looks for an arrangement that produces valid English. Common digram frequencies (TH at 1.5%, HE at 1.3%, ER at 1.2%) give strong hints about which columns belong adjacent to each other. Computer-assisted anagram solving uses these digram frequencies as a scoring function to rank candidate column orderings.

Frequency analysis on columns when key length is known. If additional plaintext properties are known — for example, that the plaintext begins with a fixed header like REPORTS or contains a known signature line — the analyst can use the frequency profile of each column to anchor candidates. For double transposition, the same techniques apply but the search space is the Cartesian product of the two key permutations, which is why double transposition stayed field-secure significantly longer than single transposition.

Comparison: Columnar Transposition vs. Other Classical Ciphers

All of the ciphers in the table below are classical, all are considered broken against modern adversaries, and all are useful as teaching tools. The comparison highlights which type of weakness each cipher exhibits and the practical keyspace size — keyspace alone does not determine security (Vigenère's keyspace is huge but it is broken by Kasiski examination), but it sets a floor for the work required to break each one.

Classical Cipher Comparison: Type, Keyspace, and Primary Cryptanalytic Weakness
Cipher Type Keyspace Primary Weakness Status
Caesar Monoalphabetic substitution 25 shifts Brute force in 25 tries Broken
Vigenère Polyalphabetic substitution 26k for key length k Kasiski examination, IC analysis Broken
Playfair Digraph substitution 25! permutations Digram frequency, known-plaintext Broken
Columnar Transposition Transposition k! for key length k Anagram solving, IC column detection Broken
ADFGX Substitution + transposition (product) 25! × k! Two-stage cryptanalysis, traffic analysis Broken (1918, Painvin)
Rail Fence Transposition Roughly 10 useful rail counts Trivial brute force Broken
Caesar and Vigenère substitute letters; columnar transposition and rail fence rearrange them; Playfair operates on digraph pairs; ADFGX combines substitution and transposition. Every cipher in this table is solvable by a laptop in under a second.

The key insight from this comparison is that combining cipher techniques (as ADFGX did) is dramatically more secure than any single technique. Modern ciphers like AES generalize this insight by iterating substitution and permutation across many rounds with cryptographically chosen — not keyword-chosen — components.

Frequently Asked Questions

Against any modern adversary with a laptop, columnar transposition is broken in seconds. A short keyword permutation has only k! possible orderings (5! = 120, 8! = 40320, 10! = 3.6 million), all trivially exhaustible. Even without brute force, ciphertext is vulnerable to column-period detection via index of coincidence followed by anagram solving on candidate column arrangements. It offers zero confidentiality against any well-resourced opponent and is suitable only for puzzles, CTF challenges, and historical study — never for protecting real information.
ADFGX was a German field cipher deployed in March 1918, replaced two months later by the expanded ADFGVX. It combined two classical techniques: a 5×5 Polybius square substitution that converted each plaintext letter into a pair of letters drawn from {A, D, F, G, X} (chosen because those Morse code symbols were maximally distinguishable over noisy telegraph lines), followed by a columnar transposition over the substituted output. The two-stage construction was significantly harder to break than either component alone, but French cryptanalyst Georges Painvin broke it in June 1918 — partly by exploiting traffic from a single critical message known as the Radiogram of Victory.
Double columnar transposition applies the cipher twice with two different keywords, taking the ciphertext from the first pass and re-encrypting it as the plaintext of the second. This thwarts simple column anagramming because the columns from pass one are scrambled into entirely new positions before pass two, destroying the per-column letter-frequency signatures that single transposition leaks. Used heavily by Allied agents in World War II and by Soviet diplomatic communications, double transposition was considered field-secure into the late 1930s before more systematic cryptanalytic methods reached it.
Yes — any string of letters works as a key, and longer keys produce more columns and a stronger transposition. The phrase TRANSPOSITION becomes the 13-character key T-R-A-N-S-P-O-S-I-T-I-O-N, then the column-read order is derived by assigning each letter its alphabetical rank position with ties broken left-to-right. Spaces and punctuation in the phrase are stripped first. The practical limit is workspace: very long keys create very wide grids that are awkward to read by hand, which is why historical operators usually capped phrase keys at 10–20 characters.
The index of coincidence (IC) is the probability that two randomly selected letters from a text are identical. For natural English the value sits near 0.067; for uniform random text it sits near 0.038 (1/26). The IC is invariant under transposition because rearranging letters does not change which letters are present — only their order. Cryptanalysts exploit this by writing the ciphertext into candidate column widths and measuring the per-column IC: when the candidate width matches the true key length, each column's IC will be near the English value of 0.067, because each column was filled with natural-language letters before transposition. Wrong widths produce a near-random IC across columns.
No. Modern symmetric ciphers like AES use substitution-permutation networks where each round applies non-linear substitution (S-boxes), bitwise permutation, and key mixing, repeated 10–14 times. Pure columnar transposition contributes no non-linearity and leaks letter-frequency information, so it cannot stand alone. Permutation does appear inside AES — the ShiftRows step performs a fixed per-row byte rotation — but that single permutation is one ingredient in a much larger construction, not a complete cipher. Treat columnar transposition as a teaching tool for understanding how diffusion works in modern designs, never as a deployable algorithm.
Number each key letter by its alphabetical rank: A=1, B=2, and so on up to Z=26. For ZEBRA, the rank values are Z=26, E=5, B=2, R=18, A=1. Then rewrite those ranks as relative positions from smallest to largest among the keyword's letters: A is rank 1 (smallest, position 1), B is rank 2 (position 2), E is rank 5 (position 3), R is rank 18 (position 4), Z is rank 26 (position 5). Putting those positional numbers back under the original key gives the column read order 5-3-2-4-1, meaning column 5 (A) is read first, then column 3 (B), then column 2 (E), then column 4 (R), then column 1 (Z). For duplicate letters, break ties left-to-right by their original position in the keyword.
Rail-fence and columnar transposition are both pure transposition ciphers, but they differ in their permutation pattern. Rail-fence writes the plaintext in a zigzag pattern across a fixed number of rails (rows), then reads off each rail in sequence — the key is just the rail count, typically 2 to 5. Columnar transposition writes the plaintext in fixed-width rows under a keyword, then reads off columns in the order specified by the keyword's alphabetical ranking. Rail-fence has a tiny keyspace (a handful of rail counts) and is trivially broken by trying each one; columnar transposition has k! orderings for a k-letter key and additionally hides the column read order, making it noticeably stronger than rail-fence though still weak by modern standards.