Question
1. Implement a Python program which executes the CFB mode of operation, for the following block cipher:
• The block cipher performs encryption first by XORing a 4 byte plaintext input block with the last 4 bytes of your student id.
E.g. Student id “R1020341” -> last 4 bytes = “0341” = 0x30333431. The result is then rotated left by 3. E.g. bytes [1,2,3,4] ->[4,1,2,3]
Use ANSI X9.23 for padding.
My Student Number = R00118019
2. Show the output of your program, using the numeric value from your student ID as the initialisation vector (e.g. student id “R1020341” -> IV= 1020341), when used to encrypt the input string:
I love long input!
3. Decrypt the resulting ciphertext (again showing all output from your program). Include clear concise comments in your program to indicate what everything does. Clearly indicate which version of Python you used.
Solution Preview
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.
#XOR two stringsdef xor_string(string1, string2):
#We first convert these 2 strings to bytes array
bytes1 = [ord(character) for character in string1]
bytes2 = [ord(character) for character in string2]
result = ""
#XOR each bytes and add to result
for i in range(len(bytes1)):
result = result + chr(bytes1[i] ^ bytes2[i])
return result
def encrypt(plain_text, IV):
plain_text_length = len(plain_text)
number_of_blocks = plain_text_length//4...
By purchasing this solution you'll be able to access the following files:
Solution.py.