The Affine cipher is a type of substitution cipher rooted in modular arithmetic, which falls under the category of monoalphabetic ciphers. It has origins in classical cryptography, dating back to the use of basic substitution techniques by ancient civilizations. While there isn’t a single, clear creator or exact date for the invention of the affine cipher specifically, it embodies methods commonly attributed to early cipher systems used throughout history, such as by Roman and Greek scholars.
The Affine cipher was used primarily for its simplicity and ease of implementation, especially before more advanced encryption techniques became prevalent. Its structure allows a single mathematical transformation to be applied to each letter in the alphabet, making it a basic but effective way of encoding messages in settings where highly complex ciphers were impractical. Its use has dwindled with the advent of modern encryption methods, but it still serves as a fundamental example in the study of classical cryptography and modular mathematics.
In the affine cipher, each letter in the plaintext message is transformed using the formula:
where:
- is the encrypted letter,
- is the numerical position of the plaintext letter (e.g., , , ..., in a 26-letter alphabet),
- and are keys that define the cipher (with being coprime to ),
- is the size of the alphabet (typically 26 for the English alphabet).
To decrypt the message, the formula:
is used, where
is the modular multiplicative inverse of modulo .Example
Let’s say we choose
and as our keys, and we want to encrypt the word "HELLO".- Convert each letter to its numeric position:
- H = 7
- E = 4
- L = 11
- L = 11
- O = 14
- Apply the encryption formula :
- For H (7): → R
- For E (4): → C
- For L (11): → L
- For L (11): → L
- For O (14): → A
So, "HELLO" becomes "RCLLA" after encryption.
Affine Cipher Table (a=5, b=8)
Plaintext | Numeric Value | Encrypted (5x + 8) | Encrypted Letter |
---|---|---|---|
A | 0 | 8 | I |
B | 1 | 13 | N |
C | 2 | 18 | S |
D | 3 | 23 | X |
E | 4 | 2 | C |
F | 5 | 7 | H |
G | 6 | 12 | M |
H | 7 | 17 | R |
I | 8 | 22 | W |
J | 9 | 1 | B |
K | 10 | 6 | G |
L | 11 | 11 | L |
M | 12 | 16 | Q |
N | 13 | 21 | V |
O | 14 | 0 | A |
P | 15 | 5 | F |
Q | 16 | 10 | K |
R | 17 | 15 | P |
S | 18 | 20 | U |
T | 19 | 25 | Z |
U | 20 | 4 | E |
V | 21 | 9 | J |
W | 22 | 14 | O |
X | 23 | 19 | T |
Y | 24 | 24 | Y |
Z | 25 | 3 | D |
This table illustrates how each letter in the alphabet is transformed when using
and . The affine cipher provides a systematic way to substitute letters and is foundational in understanding the mechanics of basic cryptographic transformations.