Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
61 views3 pages

Solutions

The document contains solutions to various exercises related to cryptography, including the Affine Cipher, Playfair code, Vigenere cipher, and Hill Cipher. Each exercise provides step-by-step calculations for encryption and decryption using specified keys and methods. The solutions demonstrate the application of mathematical concepts in encoding and decoding messages.

Uploaded by

Farkhanda batool
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views3 pages

Solutions

The document contains solutions to various exercises related to cryptography, including the Affine Cipher, Playfair code, Vigenere cipher, and Hill Cipher. Each exercise provides step-by-step calculations for encryption and decryption using specified keys and methods. The solutions demonstrate the application of mathematical concepts in encoding and decoding messages.

Uploaded by

Farkhanda batool
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

EECE 632 – Cryptography and Computer Security

Homework #1 – Solution

CHAPTER 2
Exercise #1

A generalization of the Caesar Cipher is the Affine Cipher given by: C = (a.P + b) mod 26,
Where P is the plain character and C is the cipher character after encryption, a and b are
coefficients. The decryption of the Affine Cipher is given by: P = a-1(C – b) mod 26, where a-1 is
the inverse of a mod 26. Note that characters are assigned values of A=0 and Z=25.
a) Encrypt “HI” using the Affine Cipher with a = 11 and b = 5.
b) The cipher “ME” was obtained after Affine encryption with a = 11 and b = 5. Decrypt it.

a) P = HI ⇒ P1 = 7 (H) and P2 = 8 (I)


C1 = (a.P1 + b) mod 26 = (11x7 + 5) mod 26 = 82 mod 26 = 4 = E
C2 = (a.P2 + b) mod 26 = (11x8 + 5) mod 26 = 93 mod 26 = 15 = P
⇒ C = EP 10 POINTS
b) C = ME ⇒ C1 = 12 (M) and C2 = 4 (E)
By inspection: a-1 = 19
Check: axa-1 mod 26 = 11x19 mod 26 = 209 mod 26 = 1 ü
P1 = a-1(C1 – b) mod 26 = 19(12 – 5) mod 26 = 3 = D
P2 = a-1(C2 – b) mod 26 = 19(4 – 5) mod 26 = 7 = H
⇒ P = DH 10 POINTS

Exercise #2

We know that the most frequent letters of the English alphabet are E and T. After doing Affine
encryption to a plaintext, the most frequent letters became J and k. Break the code by finding the
values of a and b.

E = 4 becomes J = 9
T = 19 becomes K = 10
C = (a.P + b) mod 26
⇒ 9 = (4a + b) mod 26 eq. 1
& 10 = (19a + b) mod 26 eq. 2
Subtract eq. 1 from eq. 2 to remove b: 1 = (15a) mod 26
By inspection: a = 7 10 POINTS
Check: 15x7 mod 26 = 105 mod 26 = 1ü
Get b from eq. 1: 9 = (4x7 + b) mod 26
By inspection: b = 7 10 POINTS
Check: (4x7 + 7) mod 26 = 35 mod 26 = 9 ü
Exercise #3

Use Playfair code to encrypt the message “HELLOS” using the keyword “homework”.

The matrix is: 10 POINTS


H O M E W
R K A B C
D F G I/J L
N P Q S T
U V X Y Z
HE LX LO SX
HE becomes OW
LX becomes GZ
LO becomes FW
SX becomes QY
C = OWGZFWQY 10 POINTS

Exercise #4

Using Vigenere cipher, encrypt the word “assignment” using the key “cryptology”.

Key c r y p t o l o g y
Plain a s s I g n m e n t
Cipher c j q x z b x s t r 10 POINTS

Exercise #5

5 8
Use the Hill Cipher with key K= in order to encrypt “DOGS”. Use the same cipher to
17 3
decrypt “PLAN”.

a) D = 3
O = 14
G=6
S = 18

5 8 3 127 23 X
C1 = K.P1 mod 26 = = mod 26 = =
17 3 14 93 15 P
5 8 6 174 18 S
C2 = K.P2 mod 26 = = mod 26 = =
17 3 18 156 0 A
⇒ C = XPSA 10 POINTS

b) P = 15
L = 11
A=0
N = 13
5 8
K=
17 3
Det(K) = 5x3 – 8x17 mod 26 = -121 mod 26 = 9
By inspection: 9-1 = 3
Check: 3x9 mod 26 = 27 mod 26 = 1 ü
3 −8 9 −24 𝟗 𝟐
⇒ K-1 = 3 mod 26 = mod 26 = 10 POINTS
−17 5 −51 15 𝟏 𝟏𝟓
9 2 15 157 1 B
P1 = K C1 mod 26 =
-1 = mod 26 = =
1 15 11 180 24 Y
9 2 0 26 0 A
P2 = K C2 mod 26 =
-1 = mod 26 = =
1 15 13 195 13 N
⇒ P = BYAN 10 POINTS

You might also like