The Columnar Transposition cipher is a transposition cipher that rearranges letters by writing the message into rows of a grid and then reading the columns in a scrambled order determined by a keyword. Like the Rail Fence cipher, the letters themselves never change — only their positions. This cipher was widely used by military forces through both World Wars.
Imagine writing your message into a grid, left to right, row by row, where each column is labeled with a letter of the keyword. Then, instead of reading the grid left to right, you read the columns in alphabetical order of their keyword letters. The keyword determines the scrambled reading order.
The message written into rows, with columns numbered by the alphabetical order of the keyword letters. Read the columns in numerical order (1, 2, 3, …) to produce the ciphertext.
Like the Rail Fence cipher, the letter frequencies of the ciphertext are identical to the plaintext frequencies — because no letters were changed, only rearranged. Frequency analysis immediately tells an attacker that a transposition cipher was used.
To decrypt, reverse the process: figure out how many rows there are, fill the ciphertext back into the columns in numerical order, then read the grid row by row to recover the plaintext.
The Rail Fence cipher has very few possible keys — just the number of rails (usually 2–10). The Columnar Transposition cipher's key space depends on the keyword length: a keyword of length n gives n! possible column orderings. A 6-letter keyword gives 720 possibilities; a 10-letter keyword gives over 3.6 million. While still not enormous by modern standards, this is a significant improvement over the Rail Fence.
Disclaimer: these pages are educational demos provided as-is, with no warranty of any kind. The author is not responsible for any consequences arising from their use.
Send comments and bug reports to chris@chrisspackman.com.
Version 0.1 — Last updated: 2026-02-21
This page is Copyright © 2025 – 2026
Chris Spackman <chris@chrisspackman.com>.
This web site developed entirely on GNU/Linux with Free / Open Source Software.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.