m373 shift cipher

18
Shift and affine ciphers, Number with different bases, Hong-Jian Lai Department of Mathematics West Virginia University Morgantown, WV – p. 1/??

Upload: cahya-chaqiqi

Post on 14-Jul-2016

8 views

Category:

Documents


2 download

DESCRIPTION

Shift Chiper

TRANSCRIPT

Page 1: M373 Shift Cipher

Shift and affine ciphers,Number with different

bases,Hong-Jian Lai

Department of Mathematics

West Virginia University

Morgantown, WV

– p. 1/??

Page 2: M373 Shift Cipher

Decoding Shift-cipher

Alphabet: Z26.

Problem: Decode a ciphertext wklvverxogehtxlwhhdvb

encoded with a shift cipher

allshift(’wklvvkrxogehtxlwhhdvb’)

thisshouldbequiteeasy (plain text can be found in theoutput)

– p. 2/??

Page 3: M373 Shift Cipher

Decoding Shift-cipher

Alphabet: Z26.

Problem: Decode a ciphertext wklvverxogehtxlwhhdvb

encoded with a shift cipher

allshift(’wklvvkrxogehtxlwhhdvb’)

thisshouldbequiteeasy (plain text can be found in theoutput)

– p. 2/??

Page 4: M373 Shift Cipher

Decoding Shift-cipher

Alphabet: Z26.

Problem: Decode a ciphertext wklvverxogehtxlwhhdvb

encoded with a shift cipher

allshift(’wklvvkrxogehtxlwhhdvb’)

thisshouldbequiteeasy (plain text can be found in theoutput)

– p. 2/??

Page 5: M373 Shift Cipher

Decoding Shift-cipher

Alphabet: Z26.

Problem: Decode a ciphertext wklvverxogehtxlwhhdvb

encoded with a shift cipher

allshift(’wklvvkrxogehtxlwhhdvb’)

thisshouldbequiteeasy (plain text can be found in theoutput)

– p. 2/??

Page 6: M373 Shift Cipher

Encoding with an affine cipher

Alphabet: Z26.

Problem: Encrypt the plain text ’meetmeinstlouis’ withan affine cipher E3,7(x) ≡ 3x + 7

affinecrypt(’meetmeinstlouis’, 3, 7)ans = rttmrtfujmoxpfj (ciphertext in the output).

– p. 3/??

Page 7: M373 Shift Cipher

Encoding with an affine cipher

Alphabet: Z26.

Problem: Encrypt the plain text ’meetmeinstlouis’ withan affine cipher E3,7(x) ≡ 3x + 7

affinecrypt(’meetmeinstlouis’, 3, 7)ans = rttmrtfujmoxpfj (ciphertext in the output).

– p. 3/??

Page 8: M373 Shift Cipher

Encoding with an affine cipher

Alphabet: Z26.

Problem: Encrypt the plain text ’meetmeinstlouis’ withan affine cipher E3,7(x) ≡ 3x + 7

affinecrypt(’meetmeinstlouis’, 3, 7)ans = rttmrtfujmoxpfj (ciphertext in the output).

– p. 3/??

Page 9: M373 Shift Cipher

Decoding with an affine cipher

Alphabet: Z26.

Problem: The cipher text ’rttmrtfujmoxpfj’ wasencrypted using the affine function f(x) = 3x + 7 inZ26. Decrypt it.

(Step 1: ) Compute the inverse functionf−1(y) ≡ 9y + 15 (mod 26).

(Step 2: ) Decryption using matlab:affinecrypt(’rttmrtfujmoxpfj’, 9, 15)ans = meetmeinstlouis

– p. 4/??

Page 10: M373 Shift Cipher

Decoding with an affine cipher

Alphabet: Z26.

Problem: The cipher text ’rttmrtfujmoxpfj’ wasencrypted using the affine function f(x) = 3x + 7 inZ26. Decrypt it.

(Step 1: ) Compute the inverse functionf−1(y) ≡ 9y + 15 (mod 26).

(Step 2: ) Decryption using matlab:affinecrypt(’rttmrtfujmoxpfj’, 9, 15)ans = meetmeinstlouis

– p. 4/??

Page 11: M373 Shift Cipher

Decoding with an affine cipher

Alphabet: Z26.

Problem: The cipher text ’rttmrtfujmoxpfj’ wasencrypted using the affine function f(x) = 3x + 7 inZ26. Decrypt it.

(Step 1: ) Compute the inverse functionf−1(y) ≡ 9y + 15 (mod 26).

(Step 2: ) Decryption using matlab:affinecrypt(’rttmrtfujmoxpfj’, 9, 15)ans = meetmeinstlouis

– p. 4/??

Page 12: M373 Shift Cipher

Decoding with an affine cipher

Alphabet: Z26.

Problem: The cipher text ’rttmrtfujmoxpfj’ wasencrypted using the affine function f(x) = 3x + 7 inZ26. Decrypt it.

(Step 1: ) Compute the inverse functionf−1(y) ≡ 9y + 15 (mod 26).

(Step 2: ) Decryption using matlab:affinecrypt(’rttmrtfujmoxpfj’, 9, 15)ans = meetmeinstlouis

– p. 4/??

Page 13: M373 Shift Cipher

Converting numbers in different bases

Problem: Convert a number-26 number (HPAC)26 tobase-10.

Find the numerical values H = 7, P = 15, A = 0 andC = 2.

Use matlab to compute:n = 7 ∗ 263 + 15 ∗ 262 + 2

n = 133174

– p. 5/??

Page 14: M373 Shift Cipher

Converting numbers in different bases

Problem: Convert a number-26 number (HPAC)26 tobase-10.

Find the numerical values H = 7, P = 15, A = 0 andC = 2.

Use matlab to compute:n = 7 ∗ 263 + 15 ∗ 262 + 2

n = 133174

– p. 5/??

Page 15: M373 Shift Cipher

Converting numbers in different bases

Problem: Convert a number-26 number (HPAC)26 tobase-10.

Find the numerical values H = 7, P = 15, A = 0 andC = 2.

Use matlab to compute:n = 7 ∗ 263 + 15 ∗ 262 + 2

n = 133174

– p. 5/??

Page 16: M373 Shift Cipher

Converting and Base-10 number to a base-b

number

Problem: Convert the base-10 number n = 13245 tobase-26.

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

The answer is n = (1 24 25)26 = (BY Z)26.

– p. 6/??

Page 17: M373 Shift Cipher

Converting and Base-10 number to a base-b

number

Problem: Convert the base-10 number n = 13245 tobase-26.

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

The answer is n = (1 24 25)26 = (BY Z)26.

– p. 6/??

Page 18: M373 Shift Cipher

Converting and Base-10 number to a base-b

number

Problem: Convert the base-10 number n = 13245 tobase-26.

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

The answer is n = (1 24 25)26 = (BY Z)26. – p. 6/??