Crypto tools

Affine cipher encode

Affine cipher encode, classical cipher, a puzzle not a protection, computed on your device.

Runs on your device. The file is never uploaded.

Affine cipher encode multiplies each letter position by a and adds b, defaulting to an a of 5 and a b of 8. Digits, spacing and punctuation stay exactly where they were. Nothing checks a on this side, so an even a, or 13, collides two letters and the decoder then refuses that key.

Input

Options

Questions

What is an affine cipher?

Each letter is turned into a number, multiplied by a, offset by b, then turned back into a letter, all modulo 26. Caesar is the special case where a is 1. The two numbers together are the key.

Which values of a work?

Only values that are coprime with 26: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23 and 25. An even a, or 13, maps two different letters onto the same output, so decoding becomes impossible. Pick one from that list.

How do I read the message back?

Use Affine cipher decode with the same a and b. It computes the modular inverse of a and undoes the multiplication. The same key has to go in both directions.

What happens to digits and punctuation?

They are left as they are. Only the 26 letters are mapped, so numbers, spaces and punctuation survive, which also means the shape of your text leaks through the ciphertext.

Can this protect anything?

No. There are 312 usable keys in total, so a program tries all of them in a moment, and letter-frequency analysis breaks it without trying any. It is a puzzle cipher. Use AES-GCM encrypt for real work.

Related Crypto tools