Question: Introduction Important: Before starting this assignment, it helps to have an understanding of the connection between decimal, hexadecimal, and binary numbers. To do that, review
Introduction
Important: Before starting this assignment, it helps to have an understanding of the connection between
decimal, hexadecimal, and binary numbers. To do that, review the Hexadecimal Notation PDF darr view in
presentation mode for the best experience
That is attached Once you have done this, please read the homework requirements below.
In Module we introduced the keywPk version of a block cipher algorithm that encrypts five bits at a time by
taking the input binary plaintext and first computing an XOR of it with a fivebit string then applying apermutation to the result of the previous step, and finally multiplying this result by an odd number modulo This can be represented as follows:
binary ciphertext, Because the number of bits we encrypt per block is the block size Hence, we can further generalize this block cipher algorithm to encrypt bits at a time, with the final operation being a multiplication by k modulo
We define a python implementation of this algorithm that encrypts an arbitrary length plaintext input as the function encrypt where the function parameters are as defined above. The function returns the encrypted ciphertext The algorithm this function implements is described below.
Algorithm encryptXwPk compute B from w or P split plaintext X into N chunks of exactly B bits length, first left padding X with Os if necessary ciphertext Y empty
repeat N times for each chunk x:
y blockencryptxwPk where blockencryptxwPk implements mp@subsupekPxoplusw
Yy
return Y
The arbitrary permutation is represented as an array with its values indicating the new permuted positions in
of the bits in So the bit at position in the permuted string is the bit that was at position in the input
Note, for simplicity and in this step only, we consider that position numbers increase from left to right for both
the input string and the permutation.
For example, let's say we have an bit input string where and
Also assume a permutation array Then the permuted string is
which is In other words, and
Instructions
You are provided with a skeletal implementation of this assignment in
Papy which is attached In addition, there is a helper
file, StringConversion.py this also attached
Complete the function blockencrypt given a bit string a bit string an arbitrary permutation
and an odd integer Generalize the coding of this function so that the block size is not assumed to be
but is deduced from the length of or which should all be the same. Your multiplication of which is
less than should be modulo
Then complete the function encrypt that takes an arbitrary length input binary string and returns the
encrypted string.
you should again deduce the block size appropriately.
Test this code using the test inputs embedded in comments in
Papy and verify that you get the expected outputs.
Your code should run correctly and be implemented efficiently.
Proper indentation and variable naming should be followed. Use meaningful variable names.
Use methods and functions as appropriate.
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
