Assignment 3
Due on 20/03/2023
Problem(s)
Use the following plaintext for encryption in the following questions:
Plaintext: 2210ModernCrypto
NOTE: You need to print all of the following for Part-1 (Q2) & Part-2 (Q1)
- Plaintext or original message (provided above)
- Key/Shift Value
- Ciphertext
- Decrypted text
Part-1:
- Define a function
LinearCongruentialGenerator()to generate Pseudo-Random Numbers (PRNs) with the following properties:- Length of PRN:
16 - Number of zeros (
0) in PRN:N - Here
Nis taken as input. Keep the default value (if no input) ofN = 5 - No other digit should repeat more than twice (i.e., maximum occurrence allowed = 2)
- Length of PRN:
- Define Vernam Cipher for encrypting and decrypting the message of length
16as per the following steps:- You may use
week2.pyfor implementing the XOR on strings - Generate a random number
PRNusingLinearCongruentialGenerator()(also print the `PRN` as proof) - Encrypt the given plaintext (above) using key =
PRN
- You may use
Part-2:
- Define a modified Caesar Cipher as per the given instructions:
- There is no restriction of only ‘26’ alphabets. Hence, DO NOT use value rotation.
- e.g., encryption of
Zwith shift value3should not beC. It can be any number/special characters/lower-case letter as well. - Encrypt the given plaintext (above) using key/shift value =
digital sum of your roll number(week1.pyorweek2.pycan be used for finding the digit/digital sum)
- You got a securely encrypted message using a classical substitution cipher contained in
secret.enc. Download thesecret.enc📥 and:- Read the content of
secret.enc(i.e., ciphertext) using the python file-handling concept - Decrypt and provide the actual textual information i.e. stored in
secret.enc(it should look likeM3022201_FLAG{xxxxxxxxxxxxxxxxx}) - Provide the substitution key K, used for encrypting the message and name the algorithm.
- Define a function
decipher()in Python to decrypt any ciphertext CT that is encrypted using this algorithm.
- Read the content of
* NOTE: the ‘classical substitution cipher’ used in Part-2 (Q2) is one of the basic ciphers and has already been discussed in one of the previous 3 lab sessions.