Affine Ciphers
ENCODING
What if we used an encoding scheme that features both techniques. To complicate decryption by adversaries we could first use an additive key and then a multiplicative key as described in the previous two sections. This combination will scramble our message and make it much harder to decrypt. Table 5 shows the alphabet encrypted with an additive key of 5 and a multiplicative key of 7.
DECODING
Since there are two keys we undo them one at a time, in reverse order as they were applied to the message. We first multiply the values of the letters of the cipher text by the inverse of the multiplicative key. We then add the inverse additive key.
BREAKING THE CODE
To break this type of encryption we will need two suspected correlations between letters. Since e and t are the first and second most frequent letters, we do a letter frequency count on the intercepted message. Say the most frequent letter is R and the second is S. Then we need to solve the pair of equations
e → R and t → S
m (a + 5) = 18 mod 26 m (a + 20) = 19 mod 26
Where m is the multiplicative key and a is the additive key.
ma + 5m = 18 mod 26 ma + 20m = 19 mod 26
Subtracting one equation from the other
(ma + 20m) - (ma + 5m) = (19 - 18) mod 26
ma - ma + 20m - 5m = 1 mod 26
15m = 1 mod 26
enough fiddling yields m = 7. Plug m = 7 into the first original equation
7 (a + 5) = 18 mod 26
7a + 35 = 18 mod 26
7a = (18 - 35) mod 26 = -17 mod 26 = 9 mod 26
7a = 9 mod 26
a = 5
Table 5: Affine Cipher with Add. Key = 5 & Mult. Key = 7
|
PlainText |
# |
Add 5 |
Mod 26 |
Mult 7 |
Mod 26 |
CodeText |
|
a |
1 |
6 |
6 |
42 |
16 |
P |
|
b |
2 |
7 |
7 |
49 |
23 |
W |
|
c |
3 |
8 |
8 |
56 |
4 |
D |
|
d |
4 |
9 |
9 |
63 |
11 |
K |
|
e |
5 |
10 |
10 |
70 |
18 |
R |
|
f |
6 |
11 |
11 |
77 |
25 |
Y |
|
g |
7 |
12 |
12 |
84 |
6 |
F |
|
h |
8 |
13 |
13 |
91 |
13 |
M |
|
i |
9 |
14 |
14 |
98 |
20 |
T |
|
j |
10 |
15 |
15 |
105 |
1 |
A |
|
k |
11 |
16 |
16 |
112 |
8 |
H |
|
l |
12 |
17 |
17 |
119 |
15 |
O |
|
m |
13 |
18 |
18 |
126 |
22 |
V |
|
n |
14 |
19 |
19 |
133 |
3 |
C |
|
o |
15 |
20 |
20 |
140 |
10 |
J |
|
p |
16 |
21 |
21 |
147 |
17 |
Q |
|
q |
17 |
22 |
22 |
154 |
24 |
X |
|
r |
18 |
23 |
23 |
161 |
5 |
E |
|
s |
19 |
24 |
24 |
168 |
12 |
L |
|
t |
20 |
25 |
25 |
175 |
19 |
S |
|
u |
21 |
26 |
0 |
0 |
0 |
Z |
|
v |
22 |
27 |
1 |
7 |
7 |
G |
|
w |
23 |
28 |
2 |
14 |
14 |
N |
|
x |
24 |
29 |
3 |
21 |
21 |
U |
|
y |
25 |
30 |
4 |
28 |
2 |
B |
|
z |
26 |
31 |
5 |
35 |
9 |
I |
Since the additive key used to encipher the message was 5 and the multiplicative key was 7 , we would want to use the inverses of these to decrypt the message. First we would multiply by 15 mod 26 (see table 3) and then add 21 mod 26 (since 26 - 5 = 21).
That’s a pain in the neck, which is the point. A higher level of complexity and sophistication in the encryption technique implies a higher level of security. In practice these days, the grunt work of any encryption/decryption would be done by computer. Click here to download software that will assist in these efforts.
You try it!
Affine Encryption: Encrypt the following message with an additive key of 3 and a multiplicative key of 7.
Plain Text |
t |
o |
d |
a |
y |
|
Value |
|
|
|
|
|
|
+ 3 |
|
|
|
|
|
|
mod 26 |
|
|
|
|
|
|
x 7 |
|
|
|
|
|
|
mod 26 |
|
|
|
|
|
|
Cipher Text |
|
|
|
|
|
Affine Decryption: You intercept this message from the enemy and think it uses an affine cipher. Assume e → X and t → Q.
Cipher Text |
T |
Y |
Q |
J |
S |
Z |
X |
V |
X |
X |
Q |
|
Value |
|
|
|
|
|
|
|
|
|
|
|
|
x inverse |
|
|
|
|
|
|
|
|
|
|
|
|
mod 26 |
|
|
|
|
|
|
|
|
|
|
|
|
+ inverse |
|
|
|
|
|
|
|
|
|
|
|
|
mod 26 |
|
|
|
|
|
|
|
|
|
|
|
|
Plain Text |
|
|
|
|
|
|
|
|
|
|
|