You are on page 1of 1

I used ASCII codes to convert letters to numeric

equivalents. The default ASCII for a = 97; For convenience


an initial shift of -97 is used so that a = 0.

Linear transformations on the set of integers modulo 26: shift and


affine mapping

Basic Shift Mapping (Caesar Cipher)

General Programming structure


Affine/Shift
string of characters:
x1x2x3x4

xn

Function

Ciphertext
function for
letter x

Cn

n+1

Encryptions of hello:
Shift mapping with a = 13: uryyb
Affine mapping with b = 5, c = 3 (Blue): mxggv
Affine map with b = 7, c = 11 (Green): inkkf

Affine Mapping

function for letter x

f(x) = bx + c (mod 26)

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z

25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0

CIPHER

f(x) = x + a (mod 26)

Conditions:
b is coprime to 26 for uniqueness
it is redundant to have c > 25

Standard Cryptanalysis Process

Statistical attack
For affine and shift maps, the parameters of the encryption function can often be inferred by
looking at how frequently letters appear in the message. This helps to slim down the
possibilities by matching letters. Modular arithmetic can then be used to deduce the parameter
keys (a, b or c).
E.g. The letter E statistically in the English language. If the letter A appears most in a message
then it is plausible to assume A = E. Hence a = 4.

Deducing affine shifts from modular simultaneous equations:


if

4 = b (2) + c (mod 26)


19 = b (5) + c (mod 26)

15 * (inverse of 3) = b
b= 15*9 mod 26 = 5
c = 20

subtracting equations: 15 = 3b mod 26

Brute force recognition

Yes
0

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

B C D E

G H

M N O P

Q R

S T

U V W X Y

a =0

Recognisable
output?

trial a,b

No

Z
a+1

Affine Map: Blue represents b = 5 , c =. 3 Green represents b = 7, c = 11

given
information:
C = E,
F=T

You might also like