Skip to main content
  1. Resources/
  2. Study Materials/
  3. Information & Communication Technology Engineering/
  4. ICT Semester 5/
  5. Cyber Security (4353204)/

6 mins· ·
Milav Dabgar
Author
Milav Dabgar
Experienced lecturer in the electrical and electronic manufacturing industry. Skilled in Embedded Systems, Image Processing, Data Science, MATLAB, Python, STM32. Strong education professional with a Master’s degree in Communication Systems Engineering from L.D. College of Engineering - Ahmedabad.
Columnar Transposition Cipher

Columnar Transposition Cipher

Advanced Transposition Cryptography

Rearranging Text for Security

Columnar Transposition Cipher Process

What is Columnar Transposition?

Columnar Transposition Cipher is a transposition cipher that arranges plaintext in a rectangular grid and reads out the ciphertext by columns in a specified order.

Key Characteristics:

  • Grid-based: Text arranged in rows and columns
  • Character preservation: Original letters maintained
  • Position rearrangement: Only positions change
  • Key-dependent: Column order determined by key

Types of Columnar Transposition

Simple Columnar:

  • Fixed column width
  • Read columns in order (1,2,3...)
  • No keyword needed
  • Easier to break

Keyed Columnar:

  • Keyword determines column order
  • Columns read in key sequence
  • More secure
  • Harder to cryptanalyze

Simple Columnar Transposition

Plaintext: "ATTACKATDAWN"
Columns: 4

Step 1: Write text in rows of 4 columns
A T T A
C K A T
D A W N

Step 2: Read columns from left to right
Column 1: A C D → "ACD"
Column 2: T K A → "TKA"
Column 3: T A W → "TAW"
Column 4: A T N → "ATN"

Ciphertext: "ACDTKATWATN"

Keyed Columnar Transposition

Plaintext: "ATTACKATDAWN"
Keyword: "ZEBRA"

Step 1: Number keyword letters alphabetically
Z E B R A
5 2 1 4 3

Step 2: Write plaintext under keyword
Z E B R A
5 2 1 4 3
-----------
A T T A C
K A T D A
W N X X X ← padding

Keyed Columnar - Reading Columns

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

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

Column B(1): T T X → "TTX"
Column E(2): T A N → "TAN"
Column A(3): C A X → "CAX"
Column R(4): A D X → "ADX"
Column Z(5): A K W → "AKW"

Ciphertext: "TTXTANCAXADXAKW"

Keyword Numbering Process

Rule: Number letters based on alphabetical order
Example Keywords:

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

CRYPTO:
C=1, O=2, P=3, R=4, T=5, Y=6
C R Y P T O
1 4 6 3 5 2

SECURITY:
C=1, E=2, I=3, R=4, S=5, T=6, U=7, Y=8
S E C U R I T Y
5 2 1 7 4 3 6 8

Duplicate Letters in Keyword

Rule: Number duplicates in order of appearance
Keyword: "LETTER"

Letters in alphabetical order: E, L, R, T, T
E=1, L=2, R=3, T=4, T=5

L E T T E R
2 1 4 5 1 3

Wait! E appears twice - number in sequence:
E(first)=1, E(second)=2, L=3, R=4, T(first)=5, T(second)=6

L E T T E R
3 1 5 6 2 4

Decryption Process

Reverse the encryption process
Ciphertext: "TTXTANCAXADXAKW"
Keyword: "ZEBRA"
Grid size: 3 rows × 5 columns

Step 1: Calculate column lengths
15 characters ÷ 5 columns = 3 characters per column

Step 2: Split ciphertext by column order
Column 1: TTX (3 chars)
Column 2: TAN (3 chars)
Column 3: CAX (3 chars)
Column 4: ADX (3 chars)
Column 5: AKW (3 chars)

Decryption - Rebuilding Grid

Step 3: Place columns in keyword positions

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

Column B(1): TTX goes to position 3
Column E(2): TAN goes to position 2
Column A(3): CAX goes to position 5
Column R(4): ADX goes to position 4
Column Z(5): AKW goes to position 1

Step 4: Read rows left to right
Plaintext: "ATTACKATDAWN" (removing X padding)

Padding Strategies

Why Padding is Needed:

Text length may not fit evenly into rectangular grid

Common Padding Methods:

  • X Padding: Fill with 'X' characters
  • Null Padding: Use rare letters (Z, Q, J)
  • Random Padding: Random letters to confuse
  • Repeated Padding: Repeat last letter
Security Note: Padding can reveal information about original message length

Double Columnar Transposition

Enhanced Security: Apply columnar transposition twice with different keywords
Process:

1. Apply first columnar transposition with Key1
2. Take result as input for second transposition
3. Apply second columnar transposition with Key2
4. Result is much more secure than single transposition

Example:
Plaintext → [Key1: ZEBRA] → Intermediate → [Key2: CRYPTO] → Final Ciphertext

Decryption:
Apply transpositions in reverse order with same keys

Security Strengths

Advantages:

  • Frequency Preservation: Resists frequency analysis
  • Character Intact: Original letters unchanged
  • Key-dependent: Security depends on keyword secrecy
  • Scalable: Longer keywords = better security
  • No Equipment: Can be done manually

Security Weaknesses

Vulnerabilities:

  • Anagram Property: Ciphertext is anagram of plaintext
  • Pattern Analysis: Word patterns may remain visible
  • Known Plaintext: If part known, key can be deduced
  • Limited Key Space: Depends on keyword length
  • Digraph Analysis: Letter pair frequency analysis

Breaking Columnar Transposition

Attack Methods:

  • Anagram Solving: Rearrange letters to form words
  • Frequency Analysis: Look for common letter combinations
  • Brute Force: Try different grid dimensions
  • Dictionary Attack: Test common keywords
  • Simulated Annealing: Computational optimization
Modern Reality: Computer algorithms can break most columnar transpositions quickly

Implementation Guidelines

Best Practices:

  • Use long, random keywords
  • Avoid common words
  • Consider double transposition
  • Use irregular padding

Avoid:

  • Short keywords
  • Dictionary words
  • Predictable padding
  • Regular grid sizes

Algorithm Implementation

Python Pseudocode:

def columnar_encrypt(plaintext, keyword):
    # 1. Calculate grid dimensions
    cols = len(keyword)
    rows = ceil(len(plaintext) / cols)

    # 2. Pad plaintext if needed
    padded_text = plaintext + 'X' * (rows * cols - len(plaintext))

    # 3. Create grid and fill row by row
    grid = [padded_text[i:i+cols] for i in range(0, len(padded_text), cols)]

    # 4. Sort keyword and read columns
    sorted_keyword = sorted(enumerate(keyword), key=lambda x: x[1])
    ciphertext = ''.join([''.join(row[i] for row in grid)
                           for i, char in sorted_keyword])

    return ciphertext

Historical Usage

Real-World Applications:

  • Military Communications: Field commanders
  • Diplomatic Messages: Embassy communications
  • Commercial Telegrams: Business secrets
  • Personal Correspondence: Private letters
World War I & II: Used by various nations, often combined with other ciphers for enhanced security

Educational Value Today

Why Study This Cipher?

  • Transposition Concepts: Foundation for understanding permutations
  • Algorithm Design: Grid-based thinking
  • Cryptanalysis Skills: Pattern recognition techniques
  • Historical Context: Pre-computer cryptography
  • Programming Practice: Array and string manipulation
Modern Context: Principles used in block ciphers and data shuffling algorithms

Practice Exercise

Try This:

Encrypt: "MEETMEATTHETOWER"
Keyword: "CIPHER"

Steps:
1. Number the keyword letters
2. Create a grid (how many rows?)
3. Fill grid row by row
4. Read columns in alphabetical order

Challenge: What's the ciphertext?

Bonus: Now decrypt this message:
"HENTEHMEETEWTTOAR"
Same keyword: "CIPHER"

Key Takeaways

  • Columnar transposition rearranges character positions
  • Uses keyword to determine column reading order
  • Preserves character frequency but changes positions
  • More secure than simple substitution ciphers
  • Vulnerable to anagram and pattern analysis
  • Foundation for understanding modern transposition
Remember: Security increases with keyword length and complexity

Thank You

Questions & Discussion

Next: Symmetric Encryption Deep Dive