Assignment 2 Problem Submission Rules: 1) Detection of plagiarism will result in Failing grade. Students must do this assignment by themselves. 2) After completion, your work must be submitted to an...

1 answer below »

The aim of this assignment is to implement a Feistel cipher round function which consists of the following steps:




Assignment 2 Problem Submission Rules: 1) Detection of plagiarism will result in Failing grade. Students must do this assignment by themselves. 2) After completion, your work must be submitted to an assignment folder in D2L by a corresponding deadline. 3) Late assignments will be accepted up to 24 hours after the due date for 50% credit. Assignments submitted more than 24 hours late will not be accepted for credit. 4) It is much better to submit a partial/failed-attempt solution than none. Include the circumstances of the incompletion in your report. Problems: The aim of this assignment is to implement a Feistel cipher round function which consists of the following steps: 1. Implementing a Feistel Cipher – 70 points Step 1: The function takes as input 8 bits and the 4-bit key ??. Step 2: The binary is divided into two halves (??0 and ??0). Step 3: The function computes ??1 = ??0 and ??1 = ??0 ⊕??(??0,??), where ??(??0,??) = 2 × ??0?? ?????? 24 Step 4: The function performs a swapping of ??1 and ??1, then outputs ??1||??1. 2. Combining with Assignment 1 – 20 points Improve your implementation for 1 by using your Text Converter, so it can handle a string from a user and output a string. 3. Make some test codes to show the correctness of your implementation – 10 points Note: It is recommended to exchange a ciphertext generated by the implementation with your friend and check the decryption algorithm successfully recovers the original plaintext (you can use the discussion section in D2L). Complier requirement: The text converter must be implemented using Python version 3.9.x or higher. Students must use Python official libraries that are accessible from the webpage (https://docs.python.org/3/library/index.html). All used libraries and their purpose should be described in the report. Submission instructions: Please submit your deliverables to the D2L Assignments folder: (a) “2. Feistel Cipher”: create a txt file, copy and paste your entire Python code, save, and then submit with a written report explaining your implementation. The report should have some test inputs and screenshots of execution results, which verify the correctness of your implementation. Once you submit, D2L will perform a similarity check for your submission and show you the result. Your similarity score must be lower than 50% unless valid reasons for a high score described in the report. Otherwise, (the score -50%) will be deducted. https://docs.python.org/3/library/index.html
Answered Same DayMar 15, 2021

Answer To: Assignment 2 Problem Submission Rules: 1) Detection of plagiarism will result in Failing grade....

Neha answered on Mar 16 2021
155 Votes
77838 - feistal cipher/__pycache__/code.cpython-39.pyc
77838 - feistal cipher/code.py
import binascii
import random

# Defining BinarytoDecimal() function
def
BinaryToDecimal(binary):
string = int(binary, 2)
return string
# Function to implement bit exor
def exor(value1,value2):
temp = ""
for i in range(length):
if (value1[i] == value2[i]):
temp += "0"
else:
temp += "1"
return temp
# Random bits key generation
def rand_key(value):
key1 = ""
value = int(value)
for i in range(value):
temp = random.randint(0,1)
temp = str(temp)
key1 = key1 + temp
return(key1)
plainText = input("Please enter plain text: ")
print("Plain Text is:", plainText)
plainText_Ascii = [ord(x) for x in plainText]
plainText_Binary = [format(y,'08b') for y in plainText_Ascii]
plainText_Binary = "".join(plainText_Binary)
length = int(len(plainText_Binary)//2)
Left1 = plainText_Binary[0:length]
Right1 = plainText_Binary[length::]
m = len(Right1)
# Generate Key K1 for the
# first round
Key1= rand_key(m)
# Generate Key K2 for the
# second round
Key2= rand_key(m)
# first round of Feistel
form1 = exor(Right1,Key1)
Right2 = exor(form1,Left1)
Left2 = Right1
# Second round of Feistel
form2 = exor(Right2,Key2)
Right3 = exor(form2,Left2)
Left3 = Right2
# Cipher text
bin_data = Left3 + Right3
string_data =' '

for i in range(0, len(bin_data), 7):
temp_data = bin_data[i:i + 7]
decimal_data = BinaryToDecimal(temp_data)
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here