All articles
ciphertranspositioncolumnarclassical

Columnar Transposition Cipher: Step-by-Step Guide

How the Columnar Transposition cipher works — writing text into a grid and reading columns in keyword order. Includes encoding/decoding examples and free tool.

April 20, 20266 min readBy SolveCipher Team

The columnar transposition cipher scrambles a message by writing it into a grid row by row, then reading it out column by column in an order determined by a keyword. Unlike substitution ciphers that replace letters, transposition ciphers rearrange them — every original letter is still there, just in a different position.

This cipher was used extensively during World War I and World War II, often layered with other methods for added security. It's harder to crack than a Caesar cipher but still approachable enough to work through by hand, making it a favorite in puzzles and CTF competitions.

How the Grid Encoding Works

The process uses three inputs: the plaintext message, a keyword, and padding characters for any empty grid cells.

Step 1: Choose a Keyword

The keyword determines the column order. Each letter of the keyword is assigned a number based on its alphabetical rank. For example, with the keyword ZEBRA:

Keyword:  Z  E  B  R  A
Numbers:  5  2  1  4  3

B is alphabetically first (gets 1), then E (2), A (3), R (4), Z (5). If letters repeat, number them left to right.

Step 2: Write the Plaintext Row by Row

Write the message into a grid with as many columns as the keyword has letters. Using the message ATTACK AT DAWN with keyword ZEBRA (5 columns):

         Z  E  B  R  A
         5  2  1  4  3
Row 1:   A  T  T  A  C
Row 2:   K  A  T  D  A
Row 3:   W  N  X  X  X

Spaces are removed before encoding. Since the message (12 letters) doesn't fill the grid perfectly (5 × 3 = 15), we add padding characters — typically X — to fill the last row.

Step 3: Read Columns in Keyword Order

Read the columns in numerical order (1, 2, 3, 4, 5):

Column 1 (B): T T X
Column 2 (E): T A N
Column 3 (A): C A X
Column 4 (R): A D X
Column 5 (Z): A K W

Ciphertext: TTXTAN CAXA DXAKW

The final ciphertext is: TTXTANCAXADXAKW

The letters of the original message are all present — they've just been rearranged based on the column reading order.

Decoding Step-by-Step

Decoding requires the keyword and the ciphertext length.

Let's decode TTXTANCAXADXAKW with keyword ZEBRA.

Step 1: Determine the grid dimensions. The keyword has 5 letters (5 columns). The ciphertext has 15 characters, so 15 ÷ 5 = 3 rows.

Step 2: Determine column order from the keyword:

Z=5, E=2, B=1, R=4, A=3

Step 3: Divide the ciphertext into columns. Each column has 3 characters (15 total ÷ 5 columns). Fill columns in numerical order:

Column 1 (B): T T X
Column 2 (E): T A N
Column 3 (A): C A X
Column 4 (R): A D X
Column 5 (Z): A K W

Step 4: Place columns back in keyword position order and read rows:

         Z  E  B  R  A
         5  2  1  4  3
Row 1:   A  T  T  A  C
Row 2:   K  A  T  D  A
Row 3:   W  N  X  X  X

Reading row by row: ATTACKATDAWNXXXATTACK AT DAWN (discarding padding).

Handling Incomplete Rows

When the message length isn't a perfect multiple of the keyword length, the last row has empty cells. This is where padding characters come in.

The most common choices are X (traditional) or null characters that the recipient knows to discard. Some implementations leave the cells empty, which creates columns of unequal length — this complicates decoding slightly but is more secure since it reveals less about the message length.

For puzzle purposes, X padding is standard and expected.

Double Columnar Transposition

For significantly stronger encryption, run the transposition twice using two different keywords (or the same keyword applied twice).

  1. Encrypt the plaintext with the first keyword
  2. Take the resulting ciphertext and encrypt it again with the second keyword

Double columnar transposition was used by various intelligence agencies during WWII. The second pass scrambles the already-scrambled text, destroying the patterns that make single transposition vulnerable to analysis.

Decoding requires reversing both steps — first undo the second transposition, then undo the first.

How to Crack a Columnar Transposition

Unlike substitution ciphers, columnar transposition doesn't change letter frequencies. If you count letters in the ciphertext, they'll match normal English frequencies exactly — E will still be the most common letter. This tells a codebreaker they're dealing with a transposition cipher, not a substitution.

The main attack is anagramming columns. If you can guess the number of columns (try the factors of the ciphertext length), you can split the ciphertext into columns and try rearranging them until readable text appears.

For example, with 15 characters, possible column counts are 3, 5, or 15. Split into 5 groups of 3, then try all 120 permutations (5! = 120). A computer handles this in milliseconds. Frequency analysis on digrams (two-letter pairs) across column boundaries can narrow down the correct order quickly.

Columnar vs. Rail Fence Transposition

Both are transposition ciphers, but they scramble text differently:

The Rail Fence cipher writes text in a zigzag pattern across multiple "rails" and reads off each rail in sequence. The pattern is fixed — no keyword needed, just the number of rails.

The columnar transposition writes text in a grid and reads columns in keyword order. The keyword provides the key, and a longer keyword creates more possible arrangements.

Columnar transposition is generally considered stronger because the keyword creates a much larger key space. A 10-letter keyword has 10! = 3,628,800 possible column orderings, while a Rail Fence cipher with 10 rails has just one arrangement for that rail count.

Try the Columnar Transposition Cipher Online

Our free Columnar Transposition encoder/decoder lets you encrypt and decrypt messages with any keyword. Enter your plaintext and keyword, and the tool builds the grid and produces the ciphertext instantly. You can also use our homepage cipher tool to identify transposition-encrypted text.

Frequently Asked Questions

What happens if two letters in the keyword are the same?

When a keyword has repeated letters, they're numbered left to right. In the keyword "LLAMA," the first L gets a lower number than the second L. Most implementations follow this left-to-right convention.

Is columnar transposition still secure today?

Single columnar transposition is not secure by modern standards — computers can brute-force the column ordering quickly. Double transposition is significantly stronger but still not comparable to modern algorithms like AES. These ciphers are now used primarily for puzzles and education.

How do I know the key length for decoding?

You need either the keyword itself or its length. Without it, try the factors of the ciphertext length — those are the possible column counts. Then anagram the columns until text appears.

Can I combine columnar transposition with substitution?

Absolutely — and this is how many historical military ciphers worked. Encrypt with a substitution cipher first, then scramble with columnar transposition. This combination defeats both frequency analysis and pattern-based attacks, since the letters are both changed and rearranged.