You are on page 1of 18

Shift and affine ciphers,

Number with different

bases,
Hong-Jian Lai
Department of Mathematics
West Virginia University
Morgantown, WV

p. 1/??

Decoding Shift-cipher

Alphabet: Z26 .

p. 2/??

Decoding Shift-cipher

Alphabet: Z26 .
Problem: Decode a ciphertext wklvverxogehtxlwhhdvb
encoded with a shift cipher

p. 2/??

Decoding Shift-cipher

Alphabet: Z26 .
Problem: Decode a ciphertext wklvverxogehtxlwhhdvb
encoded with a shift cipher
allshift(wklvvkrxogehtxlwhhdvb)

p. 2/??

Decoding Shift-cipher

Alphabet: Z26 .
Problem: Decode a ciphertext wklvverxogehtxlwhhdvb
encoded with a shift cipher
allshift(wklvvkrxogehtxlwhhdvb)
thisshouldbequiteeasy (plain text can be found in the
output)

p. 2/??

Alphabet: Z26 .

p. 3/??

Encoding with an affine cipher

Alphabet: Z26 .
Problem: Encrypt the plain text meetmeinstlouis with
an affine cipher E3,7 (x) 3x + 7

p. 3/??

Encoding with an affine cipher

Alphabet: Z26 .
Problem: Encrypt the plain text meetmeinstlouis with
an affine cipher E3,7 (x) 3x + 7
affinecrypt(meetmeinstlouis, 3, 7)
ans = rttmrtfujmoxpfj (ciphertext in the output).

p. 3/??

Alphabet: Z26 .

p. 4/??

Decoding with an affine cipher

Alphabet: Z26 .
Problem: The cipher text rttmrtfujmoxpfj was
encrypted using the affine function f (x) = 3x + 7 in
Z26 . Decrypt it.

p. 4/??

Decoding with an affine cipher

Alphabet: Z26 .
Problem: The cipher text rttmrtfujmoxpfj was
encrypted using the affine function f (x) = 3x + 7 in
Z26 . Decrypt it.
(Step 1: ) Compute the inverse function
f 1 (y) 9y + 15 (mod 26).

p. 4/??

Decoding with an affine cipher

Alphabet: Z26 .
Problem: The cipher text rttmrtfujmoxpfj was
encrypted using the affine function f (x) = 3x + 7 in
Z26 . Decrypt it.
(Step 1: ) Compute the inverse function
f 1 (y) 9y + 15 (mod 26).
(Step 2: ) Decryption using matlab:
affinecrypt(rttmrtfujmoxpfj, 9, 15)
ans = meetmeinstlouis
p. 4/??

base-10.

p. 5/??

Problem: Convert a number-26 number (HP AC)26 to

base-10.
Find the numerical values H = 7, P = 15, A = 0 and
C = 2.

p. 5/??

Problem: Convert a number-26 number (HP AC)26 to

base-10.
Find the numerical values H = 7, P = 15, A = 0 and
C = 2.
Use matlab to compute:
n = 7 263 + 15 262 + 2
n = 133174

p. 5/??

number

base-26.

p. 6/??

number

Problem: Convert the base-10 number n = 13245 to

base-26.
n=1325; m=26; d0 = mod(n, m)
d0 = 25
n1=(n-d0)/m; d1 = mod(n1,m)
d1 = 24
n2=(n-d1)/m; d2 = mod(n2,m)
d2 = 1
n3 = (n2-d2)/m; d3 = mod(n3,m)
d3 = 0
p. 6/??

number

Problem: Convert the base-10 number n = 13245 to

base-26.
n=1325; m=26; d0 = mod(n, m)
d0 = 25
n1=(n-d0)/m; d1 = mod(n1,m)
d1 = 24
n2=(n-d1)/m; d2 = mod(n2,m)
d2 = 1
n3 = (n2-d2)/m; d3 = mod(n3,m)
d3 = 0
The answer is n = (1 24 25)26 = (BY Z)26 .

p. 6/??