The Affine cipher is a special case of the more general monoalphabetic substitution cipher. In affine ciphers the encryption function for a letter is <math>e(x)=(ax+b)\pmod{m}</math> where,
- <math>a</math> and <math>m</math> are coprime (otherwise <math>a</math> would have no multiplicative inverse modulo <math>m</math>).
- <math>m</math> is the size of the alphabet.
The decryption function is <math>d(x)=a^{-1}(x-b)\pmod{m}</math> where <math>a^{-1}</math> is the multiplicative inverse of <math>a</math> in the group <math>\mathbb{Z}_{m}</math> Considering the specific case of encrypting messages in English (i.e. <math>m=26</math>), there are a total of 286 non-trivial affine ciphers, not counting the trivial Caesar ciphers obtained when <math>a=1</math>. This lack of variety renders the system as highly insecure when considered in light of Kerckhoffs' Principle. Even without foreknowledge that a text were enciphered with an affine cipher, the ciphertext would have all of the vulnerabilities of ordinary monoalphabetic substitution ciphers. The cipher's primary weakness comes from the fact that if the cryptanalyst can discover (by means of frequency analysis, brute force, guessing or otherwise) the plaintext of two ciphertext characters then the key can be obtained by solving a simultaneous equation. Since we know <math>a</math> and <math>m</math> are relatively prime this can be used to rapidly discard many "false" keys in an automated system.
See also
|
Classical cryptography
|
|---|
| Ciphers: ADFGVX | Affine | Alberti | Atbash | Autokey | Bifid | Book | Caesar | Four-square | Hill | Keyword | Nihilist | Permutation | Pigpen | Playfair | Polyalphabetic | Polybius | Rail Fence | Reihenschieber | Reservehandverfahren | ROT13 | Running key | Scytale | Smithy code | Solitaire | Straddling checkerboard | Substitution | Tap Code | Transposition | Trifid | Two-square | VIC cipher | Vigenère |
| Cryptanalysis: Frequency analysis | Index of coincidence |
| Misc: Cryptogram | Bacon | Scytale | Straddling checkerboard | Tabula recta |
| History of cryptography | Cryptanalysis | Cryptography portal | Topics in cryptography |
| Symmetric-key algorithm | Block cipher | Stream cipher | Public-key cryptography | Cryptographic hash function | Message authentication code | Random numbers |


