Playfair Cipher

The Playfair Cipher is a digraph substitution cipher that encrypts pairs of letters (digraphs) using a 5x5 matrix generated from a keyword. It treats I and J as the same letter. The cipher was used extensively in military applications and remains a popular puzzle in competitive exams.

10Worksheets
200+Practice Questions
HardDifficulty
3-4 hoursHours to Master

Introduction to Playfair Cipher

The Playfair Cipher is a digraph substitution cipher that encrypts pairs of letters (digraphs) using a 5x5 matrix generated from a keyword. It treats I and J as the same letter. The cipher was used extensively in military applications and remains a popular puzzle in competitive exams.

Prerequisites

Keyword matrix generation Digraph handling Rules for same row/column/different row & column I/J substitution
Why This Matters: Playfair Cipher problems appear in 1-2 questions in advanced exams. They test understanding of digraph encryption and matrix-based substitution.

How to Solve Playfair Cipher Problems

1

Step 1: Generate the 5x5 Playfair matrix using the keyword (I and J combined)

2

Step 2: For encoding, break the plaintext into digraphs (pairs of letters)

3

Step 3: Apply Playfair rules to each digraph to get ciphertext digraphs

4

Step 4: Rules: same row → shift right; same column → shift down; different → swap columns

5

Step 5: For decoding, apply the inverse rules (shift left, shift up, swap columns)

Pro Strategy: Always create the 5x5 matrix first. Insert the keyword, remove duplicates, then fill remaining letters (I/J together). For decoding, reverse the rules: same row → left, same column → up, different → swap columns.

Example Problem

Example: Using keyword 'PLAYFAIR', decode 'KX' (assuming KX is a ciphertext digraph). Solution: Step 1: Generate matrix from 'PLAYFAIR' (remove duplicates, I/J together) Step 2: Matrix: P L A Y F I R B C D E G H K M N O Q S T U V W X Z Step 3: In 5x5 grid form: Row0: P L A Y F Row1: I R B C D Row2: E G H K M Row3: N O Q S T Row4: U V W X Z Step 4: K is at (2,3), X is at (4,3) → same column → shift up → (1,3)=B, (3,3)=S → BS Answer: BS

Pro Tips & Tricks

  • I and J are treated as the same letter (usually replace J with I)
  • If a digraph has the same letter twice, insert 'X' between them
  • If the plaintext has an odd number of letters, add 'X' at the end
  • The matrix is always 5x5 (25 cells for 25 letters, I/J share one cell)
  • Keyword can contain any letters (I/J are combined)
  • Decoding uses the inverse of encoding rules

Shortcut Methods to Solve Faster

Same row: shift right for encoding, left for decoding
Same column: shift down for encoding, up for decoding
Different: form rectangle, swap columns
Always wrap around within the 5x5 grid

Common Mistakes to Avoid

Forgetting to combine I and J in the matrix
Not inserting 'X' between double letters
Misapplying wrap-around in the grid
Using the wrong rule for different row/column (should swap columns, not rows)

Exam Importance

Playfair Cipher is an important topic for various competitive exams. Here's how frequently it appears:

SSC CGL
1-2 questions
BANKING PO
1-2 questions
RAILWAYS RRB
0-1 questions
CAT
1-2 questions
INSURANCE
1-2 questions

Ready to Master Playfair Cipher?

Start with Worksheet 1 and work your way up to expert level! Each worksheet includes:

20 practice questions
Detailed solutions
Step-by-step explanations
Start Practicing Now