IT lexicon › Security › Affine cipher

Affine cipher

Security På svenska → Updated: 2026-10-11

A monoalphabetic substitution cipher that encrypts each letter as (a·x + b) mod 26.

Letters are numbered 0–25, multiplied by a, shifted by b and reduced modulo 26. Decryption only works if a shares no factors with 26, which leaves twelve usable values and 312 keys in total — a keyspace a laptop exhausts before you finish blinking.

Its main appeal is genealogical: the Caesar cipher is the case a = 1, and Atbash is a = b = 25. It survives in textbooks as a gentle introduction to modular inverses. As protection it falls to frequency analysis, or to just two known letter pairs.

← Back to the lexicon