Join the Official Discord
Cipher guides · Grids & squares

How to Solve the Hill Cipher

A grid cipher lays the alphabet out in a square — usually 5×5, with I and J sharing a cell — and describes each letter by where it sits. Some stop there; others shuffle those coordinates or push pairs of letters through the square together.

Free tool Have one to decode right now? Use the Hill Cipher tool

How to recognise it

Digits that never go above 5, or letters drawn from a tiny set like A, D, F, G, V and X, mean coordinates. Ciphertext that always comes in an even number of letters points to a cipher that works on pairs.

Hill Cipher Letters go in pairs through a 2×2 matrix built from RAFT, read row by row with A=0. Invert the matrix (mod 26) and multiply back. A trailing X is padding.

A worked example

Message

TREASURE MAP

Key

key RAFT

Encoded

LCQUU CDFWI VS

The alphabet sits in a square, and every letter is described by where it lives. Get the square right and the rest is bookkeeping. This one is Hill Cipher. The key: key RAFT. Letters go in pairs through a 2×2 matrix built from RAFT, read row by row with A=0. Invert the matrix (mod 26) and multiply back. A trailing X is padding. Look the first pieces up in the square and they come out T R E. The answer was TREASURE MAP.

Working one out from scratch

Draw the square first, keyword and all, and keep it in front of you. Nearly every mistake on a grid cipher is a square built wrong — a repeated keyword letter left in, or J given its own cell.

Now try one

There’s a new cipher waiting today

One a day, three guesses, and a streak that breaks the moment you miss one. Today’s is cipher #61.