- Information
- AI Chat
Was this document helpful?
Affine Cipher
Course: Computer Science (ICS 2103)
335 Documents
Students shared 335 documents in this course
University: Meru University of Science and Technology
Was this document helpful?
Math 135 (Summer 2006)
Affine Ciphers, Decimation Ciphers, and Modular Arithmetic
Affine Ciphers
An encipherment scheme (or algorithm) of the form
E(x) = (ax +b) MOD 26
is called an affine cipher. Here xis the numerical equivalent of the given plaintext letter, and aand
bare (appropriately chosen) integers.
Recall that the numerical equivalents of the letters are as follows:
ABCDEFGHIJKLM
0 1 2 3 4 5 6 7 8 9 10 11 12
NOPQRSTUVWXYZ
13 14 15 16 17 18 19 20 21 22 23 24 25
Example: Encipher ITS COOL with
E(x) = (5x+ 8) MOD 26.
Solution: Filling in the following table gives
plain I T S C O O L
x8 19 18 2 14 14 11
5x+ 8 48 103 98 18 78 78 63
(5x+ 8) MOD 26 22 25 20 18 0 0 11
cipher W Z U S A A L
If y=E(x) = (ax +b) MOD 26, then we can “solve for xin terms of y” and so determine E−1(y). That
is, if y≡(ax +b) (mod 26), then y−b≡ax (mod 26), or equivalently ax ≡(y−b) (mod 26). Using
our earlier results, we see that if we multiply both sides by a−1(mod 26), then x≡a−1(y−b) (mod 26)
and so our decipherment function is
E−1(y) = a−1(y−b) MOD 26.
Example: Decipher HPCCXAQ if the encipherment function is E(x) = (5x+ 8) MOD 26.
Solution: We begin by finding the decipherment function. Since 5x≡1 (mod 26) is solved with
x≡21 (mod 26) we see 5−1(mod 26) = 21. Therefore,
E−1(y) = 21(y−8) MOD 26
and so filling in our table gives
cipher H P C C X A Q
y7 15 2 2 23 0 16
y−8-1 7 -6 -6 15 -8 8
21(y−8) -21 147 -126 -126 315 -168 168
21(y−8) MOD 26 5 17 4 4 3 14 12
plain F R E E D O M