Caesar Cipher Decoder

Affine cipher decoder

Decoded message

Mapping chart: each dot links a plain letter to its coded letter

Key a must share no factor with 26, so only 12 values work. A straight diagonal means a = 1, which is a Caesar shift.

What is an affine cipher decoder

An affine cipher decoder undoes a two-part key. To encode, each letter number x becomes (a × x + b) mod 26, with A as 0 and Z as 25.

Key b slides the alphabet like a Caesar shift. Key a stretches it. Caesar is the affine cipher with a = 1, and Atbash is a = 25, b = 25.

Key a must share no factor with 26. Any even number or 13 sends two letters to the same place, and the message can't be read back. That leaves 12 values for a and 312 keys in all.

Pick a value for key a

Top: plain letter. Bottom: where a × x sends it, with b = 0. Gold marks a letter that lands on a spot already taken.

How to decode an affine cipher by hand

  1. Find the inverse of a: the number that gives 1 when multiplied by a, mod 26. For a = 5 it is 21, since 5 × 21 = 105 = 4 × 26 + 1.
  2. Turn each coded letter into its number y.
  3. Work out 21 × (y − b) mod 26.
  4. Turn the number back into a letter.

The player decodes RCLLA with a = 5 and b = 8.

Affine cipher examples

All three use a = 5 and b = 8, the tool's starting keys. Tap Try to load one into the decoder above.

CodedPlain
Rclla oaplxHello world
Qccz qc iz zrc fipgMeet me at the park
Ihhwvc qifuAffine maps