Join the Official Discord
Cipher guides · Detective

How to Solve the Affine Cipher

No key is given. Detective days hand you the ciphertext and nothing else, so the work is finding the key — or proving which cipher it is — before you can read a word of it.

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

How to recognise it

If the card says "key unknown" or names no method at all, it's a detective day. Look at what the text keeps: word lengths, letter frequencies, which characters appear.

Affine Each letter went through a·x + b, mod 26. There are only 312 keys — find two letters you're sure of and solve for a and b, or try them all.

A worked example

Message

TREASURE MAP

Key

key unknown

Encoded

UKXDPZKX LDA

No key was given, so the first job was finding one. Word lengths and letter patterns were the evidence. This one is Affine. The key: key unknown. Each letter went through a·x + b, mod 26. There are only 312 keys — find two letters you're sure of and solve for a and b, or try them all. Once the key is pinned down, the opening letters come back as T R E. The answer was TREASURE MAP.

Working one out from scratch

Narrow it down before you decode. Count the letters, look for the one-letter words, and test the likeliest cipher first. Short words and common letters will give you the first foothold, and one correct letter usually leads to the next.

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.