Implement A Caesar Cipher Encryption and Decryption Algorithm For The Given Pseudo Function
Implement A Caesar Cipher Encryption and Decryption Algorithm For The Given Pseudo Function
Procedure:
i. Traverse the given text one character at a time
ii. For each character, transform the given character as per the rule, depending
on whether we’re encrypting or decrypting the text.
iii. Return the new string generated.
Implementation in Python:
Encryption function
# A python program to illustrate Caesar Cipher Technique
def encrypt(text, s):
result = ""
# traverse text
for i in range(len(text)):
char = text[i]
return result
# traverse text
for i in range(len(text)):
char = text[i]
return result
2. Perform the encryption and decryption using RSA algorithm for the
following”
p = 73, q = 151; plaintext M = 3314.
a. In Public key system using RSA, Bob sent a plaintext M = 3314 to Alice
using her public key. What is the generated cipher text C?
(4 marks)
Answer,
p=73, q=151 public key is e=7 M=3314
n=p*q = 73*151 =11023
Φ (n) = (p-1)(q-1) = (73-1)(151-1) = 72*150 = 10800
gcd (Φ (n), e) = gcd (10800,7) = 1, 1<e< ϕ(n)
b. A man in the middle intercept the cipher text C from Bob sent to Alice.
Discuss the complete working process how to find the plaintext M.
(6 marks)
Answer,
p=73, q=151 public key is e=7 M=3314
n=p*q = 73*151 =11023
Φ (n) = (p-1)(q-1) = (73-1)(151-1) = 72*150 = 10800
gcd(Φ (n),e) = gcd(10800,7)= 1, 1<e< ϕ(n)
= 6911543mod11023
=3314
3. One time pad algorithms are devised by Gilbert Vernam for AT&T.
Encrypt the plain text shown below by using Vernam ciphers
technique and given random number. Write your calculation.
Plaintext KNALB
Random Number: 92, 55, 83, 21, 34
Number Equivalent A – Z = 0 - 25
(10 marks)
Answer,
Plaintext: KNALB
Random Number: 92, 55, 83, 21, 34
Numeric Equivalent: A – Z = 0 – 25
Step 1:
We generate equal number of random numbers as plaintext, here random number are
already given:
Random number: 92,55,83,21,34
Plaintext: KNALB
Step 2:
We assigned number to alphabet in ascending order.
0 = A , 1 = B , 2 = C , 3 = D , 4 = E , 5 = F , 6 = G , 7 = H , 8 = I , 9 = J , 10 = K , 11
= L , 12 = M , 13 = N ,
14 = O , 15 = P , 16 = Q , 17 = R , 18 = S , 19 = T , 20 = U , 21 = V , 22 = W , 23 = X
, 24 = Y, 25 = Z
Step 3:
We change plaintext into assigned number:
K = 10, N = 13, A = 0 , L = 11, B = 1
Which is: 10,13,0,11,1
Step 4:
To encrypt text, we add random number with plaintext number:
Plaintext: 10,13,0,11,1
Random: 92,55,83,21,34
Encrypt = 102,68,83,32,35
Step 5:
If number are more the 25, we do modulo (26)
Final number = 24, 16, 5, 6, 9
Final encrypt text = YQFGJ
______________________________________________________________
M O N A R
C H Y B D
E F G I K
L P Q S T
U V W X Z
2). Algorithm to encrypt the plain text: The plaintext is split into pairs of two
letters (digraphs). If there is an odd number of letters, a Z is added to the last
letter.
For example:
If both the letters are in the same column: Take the letter below each one (going
back to the top if at the bottom).
For example:
Diagraph: "me"
Encrypted Text: cl
Encryption:
m -> c
e -> l
If both the letters are in the same row: Take the letter to the right of each one
(going back to the leftmost if at the rightmost position).
For example:
Diagraph: "st"
Encrypted Text: tl
Encryption:
s -> t
t -> l
If neither of the above rules is true: Form a rectangle with the two letters and
take the letters on the horizontal opposite corner of the rectangle.
For example:
Diagraph: "ud"
Encrypted Text: zc
Encryption:
u -> z
d -> c
Encryption:
ST == TL
UD == ZC
YI == BG
SF == PI
UN == WM
Plain text: STUDYISFUN
Key: MONARCHY
Encrypted text: TLZCBGPIWM
********END HERE**********