Cryptography & Ciphers
Affine Cipher Decoder
Decode an affine cipher with its known a and b values. Preserve spaces and punctuation while recovering the letters.
This tool runs open-source code from CyberChef by GCHQ (Apache License 2.0). See open-source credits.
The decoder applies x = a⁻¹ × (y − b) mod 26 to letters. A represents zero.
The output preserves character positions, case, spaces, and punctuation.
- Decode an affine exercise from a cryptography course when a and b are given.
Recover AFFINE CIPHER with a known key
Input: IHHWVC SWFRCP
Settings: a = 5 and b = 8.
Result: AFFINE CIPHER
Affine Cipher Decoder uses a⁻¹ = 21, because 5 × 21 = 105 = 4 × 26 + 1. I is 8, so 21 × (8 − 8) mod 26 = 0, which is A. H is 7, so 21 × (7 − 8) mod 26 = 5, which is F.
Set a and b and check invertibility
- Paste the ciphertext into Input.
- Enter the encoding multiplier a and shift b. The decoder calculates the inverse.
- Encode the result with the same settings to check the transformation.
- Only unaccented Latin letters change.
- The tool does not search unknown keys.
- The small key space makes this cipher unsuitable for secrets.