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
| a | Inverse of a modulo 26 |
|---|---|
| 1 | 1 |
| 3 | 9 |
| 5 | 21 |
| 7 | 15 |
| 9 | 3 |
| 11 | 19 |
| 15 | 7 |
| 17 | 23 |
| 19 | 11 |
| 21 | 5 |
| 23 | 17 |
| 25 | 25 |
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
HELLOa = 5; b = 8; inverse of a = 21RCLLAFor 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.
- If a is rejected, choose one of the 12 values in the table.
- For b, use any integer. The tool reduces it modulo 26, so −18 and 8 give the same shift.
- Keep the normalized a and b values with your answer sheet.
- 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?