Question: Run the following Python code that implements the product cipher example explained in class: productcipher.py import numpy as np #confusion - diffusion example using product
Run the following Python code that implements the product cipher example explained in class:
productcipher.py
import numpy as np
#confusiondiffusion example using product cipher
#plaintext message
m npmatrix
printPlaintext m
print
#XOR part of product cipher
key npmatrix
cnpmodmkey
printEncrypt c
print
#permutation part of product cipher
key npmatrix
printKey key
print
#c is the ciphertext
cckey
castypeint
cnpmodc
printEncrypt c
print
#decrypt by by first inverting the pernutation
#and then inverting the exclusive XOR
Pinvnptransposekey
chatcPinv
chat.astypeint
chatnpmodchat,
print
printP inversePinv
printDecrypt chat
print
mhatnpmodchatkey
printDecrypted ciphertext mhat
print
a Explain what the permutation matrix is doing to the bits in the plaintext.
b Use the Python script productcipher.py to construct a table relating the ciphertext to every possible bit plaintext message. Is it the case that all plaintext messages are scrambled? Is there any flaw in the system would allow an attacker to determine a key?
c Choose a single bit plaintext message and, by hand, work out each step in the
encryptiondecryption process to show how the product cipher works.
d Why is the product cipher a symmetric cipher?
e How is the product cipher similar to the Vernam cipher discussed in Unit How does it differ from the Vernam cipher?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
