An Affine cipher needs two numbers: a multiplies each letter’s position, and b shifts the result. To decode the message, every output letter must lead back to exactly one input letter. The table below lists the a values that make this possible.

Valid values of a and their inverses

aInverse of a modulo 26
11
39
521
715
93
1119
157
1723
1911
215
2317
2525

A valid a shares no factor with 26 other than 1, written gcd(a, 26) = 1. Since 26 = 2 × 13, that rules out even numbers and multiples of 13. Its inverse is the number you multiply by to get 1 modulo 26.

Verify a = 5, b = 8

A reversible key pair

InputHELLO
Settingsa = 5; b = 8; inverse of a = 21
Expected resultRCLLA
Try this method

For H = 7, 5 × 7 + 8 = 43, and 43 mod 26 = 17 or R. Decoding R uses 21 × (17 − 8) = 189, which wraps to 7 or H. The identity 5 × 21 = 105 = 1 mod 26 explains why the inverse works.

Why a = 13 fails

With a = 13, both A = 0 and C = 2 become 0 after multiplication modulo 26. Adding the same b cannot tell them apart again. The tool rejects this key because there is no unique way to decode its result.

  1. If a is rejected, choose one of the 12 values in the table.
  2. For b, use any integer. The tool reduces it modulo 26, so −18 and 8 give the same shift.
  3. Keep the normalized a and b values with your answer sheet.
  4. When decoding, enter the original a and b. The tool calculates the inverse for you.

Try a key check

Which of a = 7 and a = 14 is valid? What is the inverse of the valid value?

Affine cipher toolWork through Affine keys a = 5, b = 8How modulo 26 wraps around the alphabet