DIGRAPH SUBSTITUTION • INTERMEDIATE

Playfair Cipher

Encrypt pairs of letters through a keyed 5×5 square using row, column, and rectangle rules.

Family Polygraphic substitution
Key / parameter Keyword-derived 5×5 square
Text structure Plaintext is processed in digraphs
01 • OVERVIEW

What is the Playfair Cipher?

Playfair encrypts two letters at a time instead of one. A keyword builds a 5×5 square, normally combining I and J so 25 cells can represent the alphabet.

Each pair uses one of three geometric rules: same row, same column, or rectangle corners.

Competition note

The cipher mechanics on this page are self-contained. Science Olympiad event formats, allowed variants, and tournament constraints can change by season; the current official Rules Manual and official clarifications take precedence.

Starting from zero?

No outside reference is assumed. Work through Foundations → Complete Reference → Encryption → Decryption in order, then use the competition and cryptanalysis sections.

02 • FOUNDATIONS

What you need to know

  • Build the square by writing the keyword without repeated letters, then the remaining alphabet.
  • Treat I/J according to the convention given by the problem; this guide uses a combined I/J cell.
  • Split plaintext into pairs. If a pair contains the same letter twice, insert a filler such as X between them. Add a filler if one letter remains at the end.

Beginner glossary

Term Meaning
Digraph A pair of letters encrypted together.
Key square A 5×5 alphabet square built from a keyword.
Filler Usually X in this site; inserted to split repeated letters in a pair or pad an odd final letter.
Rectangle rule For letters in different rows and columns, use the other corners of their rectangle.
I/J convention A 5×5 English square needs one combined cell; this site combines I and J.
03 • COMPLETE REFERENCE

Keep this beside you while solving

Example square using keyword CIPHER (I/J combined).

C
I
P
H
E
R
A
B
D
F
G
K
L
M
N
O
Q
S
T
U
V
W
X
Y
Z
Situation Encryption rule Decryption rule
Same row Move each letter one cell right; wrap around. Move each letter one cell left; wrap around.
Same column Move each letter one cell down; wrap around. Move each letter one cell up; wrap around.
Rectangle Keep each row; take the other corner in the same row. Same rectangle operation.

Pair-preparation checklist

  1. Remove nonletters and convert J to I for this convention.
  2. Read left to right in pairs.
  3. If a pair would contain the same letter twice, insert X after the first letter and restart the pairing.
  4. If one letter remains at the end, append X.

Three geometry rules

Geometry Encrypt Decrypt
Same row Move each letter one cell right, wrapping. Move each letter one cell left, wrapping.
Same column Move each letter one cell down, wrapping. Move each letter one cell up, wrapping.
Rectangle Keep each letter’s row and take the other letter’s column. The same rectangle operation reverses it.
Reference rule: if a fixed table, formula, alphabet, or convention is needed to solve this cipher, it should be visible in this section or generated explicitly by the visualizer below.
04 • ENCRYPTION

How encryption works

1

Prepare the text

Remove unsupported characters, split into pairs, and insert fillers when needed.

2

Locate both letters

Find the two cells in the 5×5 square.

3

Apply one rule

Same row → right; same column → down; rectangle → opposite corners.

4

Repeat

Process every pair independently.

05 • DECRYPTION

How decryption works

1

Split ciphertext into pairs

Ciphertext length should be even.

2

Locate both cells

Use the same keyed square.

3

Reverse row/column moves

Left for same row, up for same column; rectangles use the same corner swap.

4

Interpret fillers

An X between doubled letters or at the end may be padding rather than literal plaintext.

06 • COMPETITION WORKFLOW

How to approach it in Codebusters practice

  • Keep the square visible while solving; repeatedly reconstructing it wastes time.
  • Mark I/J convention clearly before starting.
  • Work pair-by-pair and write intermediate plaintext under the ciphertext to reduce transcription errors.

What the problem gives you vs. what you produce

Part What to expect
You may be given A keyword/key square and ciphertext, or plaintext to encrypt.
You must find The opposite text by processing digraphs.
Fastest first move Build and label the 5×5 square neatly; then handle pairs one at a time.
Season note: use this page to learn the cipher mechanics and solving workflow. Exact Science Olympiad event constraints can change by season, so follow the current official rules/clarifications for tournament-specific limits.
07 • CRYPTANALYSIS

How to attack an unknown or partially known key

  • Playfair hides single-letter frequencies better than a simple substitution because it encrypts digraphs.
  • Repeated digraphs and likely crib placements can still give structure.
  • When the key/square is supplied, the task becomes deterministic; without it, cryptanalysis is substantially harder.
08 • WORKED PROBLEM

Follow one example from start to finish

Square key
CIPHER
Prepared pairs
HIDDEN CLUE → HI DX DE NC LU EX
Pair examples
HI → EP (same row); DX → BY (rectangle).
Ciphertext
EPBYFHGENSPZ
BEGINNER SELF-CHECK

Before moving on, make sure you can answer these without another site:

  • Can you explain what happens to the pair LL during preparation?
  • Can you identify which rule applies to any two cells in the square?
  • Can you reverse a same-row encrypted pair by moving left?
09 • ERROR CHECK

Common mistakes

!

Forgetting to split doubled letters in the same pair.

!

Forgetting end padding.

!

Moving the wrong direction during decryption.

!

Treating I and J as separate when the square combines them.

10 • SPEED

Competition speed strategies

1

Build the square neatly and label rows/columns mentally.

2

Circle each digraph as you finish it.

3

Check the geometry before moving letters; most errors are rule-selection errors, not arithmetic.

11 • QUICK REFERENCE

What to remember under time pressure

Grid 5×5
Unit Digraphs (2 letters)
Same row Right to encrypt / left to decrypt
Same column Down / up
Rectangle Opposite corners
How to use this section: during timed practice, come here first for the minimum rules. If a step is unclear, jump back to Complete Reference or the worked example instead of guessing.
12 • INTERACTIVE LAB

See every transformation

Use the lab to change inputs and keys, keep the relevant reference material visible, inspect each intermediate transformation, and then read the “How to reverse it” panel so encryption and decryption connect.