You are on page 1of 3

SVKM’S NMIMS (Deemed-to-be University)

MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT AND ENGINEERING


MUMBAI CAMPUS
Computer Engineering Department
LAB Manual
Experiment No.03

PART B
(PART B: TO BE COMPLETED BY STUDENTS)

Roll. No. N056 Name: Akshita Singh


Class: MBA Tech Computers Batch: B2
Date of Experiment: Date of Submission:
Grade:

B.1 Answers of Task to be written by student:


Code

def generateKey(string, key):key =


list(key)

if len(string) == len(key):
return(key)
else:
for i in range(len(string) - len(key)):key.append(key[i % len(key)])

return("" . join(key))

def cipherText(string, key):


cipher_text = []

for i in range(len(string)):
x = (ord(string[i]) + ord(key[i])) % 26x
+= ord('A') cipher_text.append(chr(x))return("" .
join(cipher_text))

def originalText(cipher_text, key):orig_text =


[]

for i in range(len(cipher_text)):
x = (ord(cipher_text[i]) - ord(key[i]) + 26) % 26x
+= ord('A') orig_text.append(chr(x))
return("" . join(orig_text))

if name == " main ": string


SVKM’S NMIMS (Deemed-to-be University)
MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT AND ENGINEERING
MUMBAI CAMPUS
Computer Engineering Department
= "MUKESHPATELNMIMS"
keyword = "AKSHITA" print("Ciphertext :",
cipher_text)print("Original/Decrypted Text
:",
originalText(cipher_text, key))

Output:

B.2 Observations and learning:


In this experiment we studied Different types of ciphers and implemented one of them in thisexperiment – Vignere
Cipher.

B.3 Conclusion:
In this experiment we studied Different types of ciphers and implemented one of them in thisexperiment – Vignere
Cipher.

B.4 Question of Curiosity


SVKM’S NMIMS (Deemed-to-be University)
MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT AND ENGINEERING
MUMBAI CAMPUS
Computer Engineering Department
1. Distinguish between substitutions and transposition ciphers.

S.N Substitution Cipher Technique Transposition Cipher Technique

1. In substitution Cipher Technique, plain In transposition Cipher Technique, plain text


text characters are replaced with other characters are rearranged with respect to the
characters, numbers and symbols. position.
2. Substitution Cipher’s forms are: Mono Transposition Cipher’s forms are: Key-less
alphabetic substitution cipher and poly transposition cipher and keyed transposition
alphabetic substitution cipher. cipher.
3. In substitution Cipher Technique, While in transposition Cipher Technique, The
character’s identity is changed while its position of the character is changed but
position remains unchanged. character’s identity is not changed.
4. In substitution Cipher Technique, The While in transposition Cipher Technique, The
letter with low frequency can detect plain Keys which are nearer to correct key can
text. disclose plain text.
5. The example of substitution Cipher is The example of transposition Cipher is Rail
Caesar Cipher. Fence Cipher.

2. Benefits of polyalphabetic substitution cipher over mono alphabetic substitution cipher.

Ans. Under different alphabets, the same plain text character is thus encrypted to different cipher text characters,
preventing simple frequency analysis as per monoalphabetic substitution. Therefore, polyalphabetic cipher
techniques make the message more secure as compared to various other techniques. In monoalphabetic
substitution, the relationship between a character in the plain text to a character in the cipher text is always one-to-
one. In polyalphabetic substitution, each occurrence of a character may have a different substitute. The relationship
between a character in the plain text to a character in the cipher text is one-to-many.

You might also like