Affine Cipher Tool

Encrypt or decrypt text with the affine cipher, using a multiplier a and a shift b. Letters keep their case, and other characters are left unchanged.

1 Paste your text and pick the options

2 Your answer

Your answer shows here as you type.

How to use the Affine Cipher Tool

  1. Type or paste the text you want to convert.
  2. Enter the multiplier a. It must share no factor with 26, so use 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23 or 25.
  3. Enter the shift b, then choose Encrypt or Decrypt.
  4. Copy the result from the output box.

Frequently asked questions

Which values of a can I use in the affine cipher?

a must be coprime with 26, so it cannot be even or a multiple of 13. The valid values from 1 to 25 are 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23 and 25. The shift b can be any whole number.

How do you decrypt an affine cipher?

Find the modular inverse of a, written a^-1, which is the number m where a times m leaves remainder 1 when divided by 26. Then compute x = a^-1 times (y - b) mod 26 for each letter value y, where A is 0 and Z is 25.

Is the affine cipher secure?

No. It has only 312 possible keys, and each letter always maps to the same letter, so frequency analysis can break it quickly. It is used for teaching rather than for protecting real data.

Wrote something with AI? Slop Monkey rewrites it so it sounds like you, and keeps your facts.