CSCI3310 Lecture 03
CSCI3310 Lecture 03
Cryptography
Associate Professor
Department of Mathematics,
Islamic University of Gaza
2022-2023, Semester 1
Cryptography
Example 1:
Encrypt the message “MEET YOU IN THE PARK” using shift
cipher with k = 3.
Solution:
1 Convert to numbers:
12 4 4 19 24 14 20 8 13 19 7 4 15 0
17 10,
15 7 7 22 1 17 23 11 16 22 18 3 20
10 7 13,
3 Translating the numbers back to letters produces the encrypted
message “PHHW BRX LQ WKH SDUN”.
► If we know the shift, then it’s easy - just run the message
through the inverse:
f − 1
(p) = (p − k) mod 26
Example 2:
Encrypt the message “STOP GLOBAL WARMING” using the shift
cipher with k = 11.
Solution:
1 Replace each letter with the corresponding element of Z26.
18 19 14 15 6 11 14 1 0 11 22 0 17 12 8 13 6.
3 4 25 0 17 22 25 12 11 22 7 11 2 23 19 24 17.
11 4 22 11 24 15 11 20 9 11 15 25 7 13 24 11 7 0 0 11 7
9 14 11 24.
Example 4:
What letter replaces the letter K when the function
a × 10 + b = 7 × 10 + 13 = 83 ≡ 5 mod 26,
Example 6:
We intercepted the message
Definition:
Example 7:
Describe the family of shift ciphers as a
cryptosystem. Solution:
Assume the messages are strings consisting of
elements in
Z26.
► P is the set of strings of elements in Z26,
► C is the set of strings of elements in Z26,
► K = Z26,
► E consists of functions of the form
Example 8:
Suppose Alice wants her friends to encrypt email messages before sending them
to her. Computers represent text as long numbers (01 for ”A”, 02 for ”B” and
so on), so an email message is just a very big number. The RSA Encryption
Scheme is often used to encrypt and then decrypt electronic communications.
General Example
Alice’s Setup: Alice’s Setup:
► Chooses ► p = 11
p, q. and q =
► Calculate k = (p − 1)(q −
► Calculates 3.
s1)n = ► n = pq
► Chooses numbers e and d so
pq. = 11.3
that e.d has a remainder of 1
= 33.
when divided by k.
► k = 10.2
► Publishes her public key (n,
= 20.
e).
► If e = 3 and d = 7, then ed =
21 has a remainder of 1 when
Dr. Bishr M. Iquelan (IUGaza) 4.6-Cryptography 1st Semester, 2022-2023 23 / 27
The RSA Encryption Algorithm
Example 8 Cont.:
Bob encrypts M for Alice: Bob encrypts message M = 14:
► Finds Alice’s public key (n, e). ► (n, e) = (33, 3).
► Finds the remainder C when M e ► When 143 = 2744 is divided by
is divided by n. 33, the remainder is C = 5.
► Sends ciphertext C to Alice. ► Sends ciphertext C = 5 to
Alice.
Alice receives & decrypts C:
► Uses her private key (n, d ). Alice decrypts ciphertext C = 5:
► (n, d ) = (33, 7).
► Finds remainder R when Cd is
divided by n. ► When 57 = 78125 is divided by
33, the remainder is R = 14.
► R matches the message M
that wanted to send to Alice!
Bob ► message
R = 14 =from
M, Bob!
the original
Example 9:
► Encrypt message ”STOP” using RSA with n = 2537, e = 13
M = 1819 1415
Example 10:
► Decrypt the cipher text 0981 0461 for the RSA cipher with
p = 43, q = 59, and e = 13.
► First we need to compute d, the inverse of e modulo
k = (p − 1)(q − 1)
► Here, k = (p − 1)(q − 1) = 2436, and to find d = e¯
solve:
13x ≡ 1 mod 2436
► To solve this, first compute s, t such that:
► Apply extended Euclidian13s + 2436t s==1 937, t = −5.
algorithm:
Thus
d = e¯ = 937
► 0981937 mod 2537 = 0704, 04619937 mod 2537 = 1115
► Thus, decrypted message is 0704 1115, or in English, ”HELP”