Modern Cryptography

Practicals for M.Sc. CS students | (M3022201)

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)

  1. Plaintext or original message (provided above)
  2. Key/Shift Value
  3. Ciphertext
  4. Decrypted text

Part-1:

  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 N is taken as input. Keep the default value (if no input) of N = 5
    • No other digit should repeat more than twice (i.e., maximum occurrence allowed = 2)
  2. Define Vernam Cipher for encrypting and decrypting the message of length 16 as per the following steps:
    • You may use week2.py for implementing the XOR on strings
    • Generate a random number PRN using LinearCongruentialGenerator() (also print the `PRN` as proof)
    • Encrypt the given plaintext (above) using key = PRN

Part-2:

  1. 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 Z with shift value 3 should not be C. 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.py or week2.py can be used for finding the digit/digital sum)
  2. You got a securely encrypted message using a classical substitution cipher contained in secret.enc. Download the secret.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 like M3022201_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.

* 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.


Back to Homepage