Columnar Transposition Cipher Examples - Learn Step by Step
Master the columnar transposition cipher through detailed, hands-on examples covering encryption, decryption, double transposition, and cryptanalysis. Each example shows every step of the process, from keyword ordering to grid construction and column reading. All examples can be verified using our columnar transposition encoder and decoder.
Example 1: Basic Encryption with Keyword ZEBRAS
This classic example demonstrates the standard columnar transposition process using the well-known keyword ZEBRAS.
Problem Setup
Plaintext: WE ARE DISCOVERED FLEE AT ONCE Keyword: ZEBRAS
Step 1: Determine column order
Sort the keyword letters alphabetically, breaking ties by position:
| Letter | Z | E | B | R | A | S |
|---|---|---|---|---|---|---|
| Position | 0 | 1 | 2 | 3 | 4 | 5 |
| Order | 6 | 3 | 2 | 4 | 1 | 5 |
Alphabetical ranking: A(pos 4)=1, B(pos 2)=2, E(pos 1)=3, R(pos 3)=4, S(pos 5)=5, Z(pos 0)=6
Step 2: Write plaintext into the grid
Remove spaces and write row by row into 6 columns:
| Z(6) | E(3) | B(2) | R(4) | A(1) | S(5) |
|---|---|---|---|---|---|
| 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 | X | X | X | X | X |
Last row padded with X.
Step 3: Read columns in order 1, 2, 3, 4, 5, 6
- Column 1 (A): EVLNX
- Column 2 (B): ACDTX
- Column 3 (E): ESEAX
- Column 4 (R): ROFOX
- Column 5 (S): DEECX
- Column 6 (Z): WIREE
Result: WE ARE DISCOVERED FLEE AT ONCE -> EVLNXACDTXESEAXROFOXDEECXWIREE
Example 2: Basic Decryption
Decrypt the ciphertext from Example 1 back to the original message.
Problem Setup
Ciphertext: EVLNXACDTXESEAXROFOXDEECXWIREE Keyword: ZEBRAS
Step 1: Calculate grid size
30 characters / 6 columns = 5 rows (exact fit, no short columns)
Step 2: Fill columns in alphabetical order
Each column gets 5 characters. Fill in order 1, 2, 3, 4, 5, 6:
Column 1 (A, position 4): E V L N X Column 2 (B, position 2): A C D T X Column 3 (E, position 1): E S E A X Column 4 (R, position 3): R O F O X Column 5 (S, position 5): D E E C X Column 6 (Z, position 0): W I R E E
Step 3: Reconstruct grid with columns in original positions
| Z(0) | E(1) | B(2) | R(3) | A(4) | S(5) |
|---|---|---|---|---|---|
| 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 | X | X | X | X | X |
Step 4: Read row by row
WEAREDISCOVEREDFLEEATONCEXXXXX
Remove padding: WE ARE DISCOVERED FLEE AT ONCE
Example 3: Short Keyword Encryption
A shorter keyword creates fewer columns, producing a different grid structure.
Problem Setup
Plaintext: ATTACK AT DAWN Keyword: KEY
Step 1: Column order
| K | E | Y |
|---|---|---|
| 2 | 1 | 3 |
Alphabetical: E=1, K=2, Y=3
Step 2: Fill the grid (removing spaces)
| K(2) | E(1) | Y(3) |
|---|---|---|
| A | T | T |
| A | C | K |
| A | T | D |
| A | W | N |
No padding needed (12 characters / 3 columns = 4 rows exactly).
Step 3: Read in order 1, 2, 3
- Column 1 (E): TCTW
- Column 2 (K): AAAA
- Column 3 (Y): TKDN
Result: ATTACK AT DAWN -> TCTWAAAATKDN
Example 4: Double Columnar Transposition
Double transposition applies two rounds of encryption for significantly stronger security.
Problem Setup
Plaintext: HELLO WORLD First keyword: CAB Second keyword: DUSK
Step 1: First encryption with keyword CAB
Column order: A=1, B=2, C=3
| C(3) | A(1) | B(2) |
|---|---|---|
| H | E | L |
| L | O | W |
| O | R | L |
| D | X | X |
Padded with X. Read columns: EORX LWLX HLOD
First pass result: EORXLWLXHLOD
Step 2: Second encryption with keyword DUSK
Column order: D=1, K=3, S=2, U=4
Wait -- sorted alphabetically: D=1, K=2, S=3, U=4
| D(1) | U(4) | S(3) | K(2) |
|---|---|---|---|
| E | O | R | X |
| L | W | L | X |
| H | L | O | D |
Read columns in order 1, 2, 3, 4: ELH XXD RLO OWL
Final ciphertext: ELHXXDRLOOWL
Double Transposition Decryption
To decrypt, reverse the process: first undo keyword DUSK, then undo keyword CAB.
Example 5: Handling Repeated Letters in Keyword
When a keyword has repeated letters, ties are broken by position (left to right).
Problem Setup
Plaintext: SECRET Keyword: BANANA
Step 1: Column order with repeated letters
| B | A | N | A | N | A |
|---|---|---|---|---|---|
| 2 | 1 | 5 | 3 | 6 | 4 |
Three A's: first A (position 1) = rank 1, second A (position 3) = rank 3, third A (position 5) = rank 4. Two N's: first N (position 2) = rank 5, second N (position 4) = rank 6. One B: B (position 0) = rank 2.
Step 2: Fill the grid
| B(2) | A(1) | N(5) | A(3) | N(6) | A(4) |
|---|---|---|---|---|---|
| S | E | C | R | E | T |
Only one row needed for 6 characters.
Step 3: Read in order 1, 2, 3, 4, 5, 6
E S R T C E
Result: SECRET -> ESRTCE
Frequently Asked Questions
Where can I find columnar transposition examples with solutions?
This page provides comprehensive columnar transposition examples with complete step-by-step solutions covering basic encryption and decryption, short keywords, double transposition, and handling repeated keyword letters. All examples include grid visualizations and can be verified using our encoder and decoder tools.
How to solve columnar transposition step by step?
To encrypt: write your keyword, number columns alphabetically, fill plaintext into the grid row by row (padding if needed), then read columns in numbered order. To decrypt: calculate grid dimensions, fill columns in alphabetical order with ciphertext segments, then read the grid row by row. See Examples 1 and 2 above for complete walkthroughs.
How does double columnar transposition work?
Encrypt the message with the first keyword as normal, then take the resulting ciphertext and encrypt it again with a second keyword. For decryption, reverse the process: decrypt with the second keyword first, then decrypt that result with the first keyword. Example 4 above demonstrates this complete process.
How do repeated letters in the keyword affect encryption?
When a keyword contains repeated letters (like BANANA), ties are broken by position from left to right. The first occurrence of a letter gets the lower rank. This ensures a unique, deterministic column order regardless of letter repetition. See Example 5 for a demonstration.
What padding character should I use?
The most common padding characters are X and Z because they are the least frequent letters in English. Some implementations use random letters or no padding at all. The choice of padding character does not affect security but can make manual decryption easier if a recognizable character is used.