Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Provided with this assignment is a Python 3 module called encryption.py with the following API: . charTobin (c) o converts a character into a list

image text in transcribedimage text in transcribedimage text in transcribed

Provided with this assignment is a Python 3 module called encryption.py with the following API: . charTobin (c) o converts a character into a list of six 1's and O's using Base64 encoding o parameter: c: char from Base64 set o return type: list of 1's and O's binToChar(b) o converts a list of six 1's and O's into a character using Base64 encoding o parameter: . b: list of 1's and O's o return type: char from Base64 set strToBin(s) o converts a string of characters into a list of 1's and O's using Base64 encoding o parameter: S: string o return type: list of 1's and O's binToStr(b list) o convert a list of 1's and O's into a string of characters using Base64 encoding o parameter: b_list: list of 1's and O's o return type: string generatePad (seed, k, 1) o returns a pseudo-random list of 1s and Os, generated by an [N, K] LFSR, where N = length of seed o parameters: seed : list of 1's and O's k: int, tap position 1: int , length of the sequence to be generated o return type: list of i's and O's encrypt (message, seed, k) o takes a string message and returns it as an encrypted string using an [N, k] LFSR o parameters: message : string of characters from Base64 set seed : list of 1's and O's k: int, tap position o return type: string This module is empty (or 'stubbed out', in CS terms). That is, all the method signatures (aka, the interface) are there, but they do not have any implementation. In this question, you will implement the methods of encryption.py, and test your code. Notes: Characters in Python are stored in ASCII, but this question is assuming characters are stored in Base64; you will need way to convert between these different encoding schemes; you must write this code yourself. You must use the exact function names, parameter types and return types shown in the API o So if the API requires a list, then make sure that a list is used! . Learning objective: code to the actual requirements, not to how you would like them to be! Write well-structured code, for example: ostrToBin() should call charToBin() to convert each character in a string into binary o similarly, binToStr() should call binToChar() similarly, encrypt() should call some of the other functions in order to work A useful module called bindec.py, has been provided, which performs binary-decimal conversion; you can make calls to this module, but you cannot modify it in any way A tester module called tester.py has been provided, which is what you have to run to get output; you cannot modify it in any way Strong suggestion: test that your code works before submission! . It should be fairly obvious what the output should be, and whether or not your module is working correctly, by examining the output when you run tester.py import sys import encryption # DO NOT CHANGE ANY CODE IN THIS FILE # DO NOT SUBMIT THIS FILE WITH YOUR ASSIGNMENT # test l: charToBin print(" l. Testing charToBin()") print ("Input: 'P'") print ("Expected: 001lll") print ("Actual: ", "encryption.charToBin('P')) # test 2: binToChar print(" 2. Testing binToChar()") print("Input: [1,0,1,1,1,0]") print ("Expected: u") print ("Actual: ", encryption.binToChar([1,0,1,1,1,0))) # test 3: strToBin print(" 3. Testing strToBin()") print("Input: Camera") print ("Expected: 000010011010100110011110101011011010") print ("Actual: ", *encryption.strToBin ("Camera")) # test 4: binToStr print(" 4. Testing binToStr(") print("Input: [1, 0, , 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0]") print ("Expected: pirate") print ("Actual: ", encryption.binToStr([1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0])) # test 5: generatePad() print(" 5. Testing generatePad(), with:") print(">seed = [1,1,0,0,0,1,1,0,0,1,0]") print(">k = 9") print(">length = 20 ") pad encryption.generatePad([1,1,0,0,0,1,1,0,0,1,0], 9, 20) print ("Expected: 1101111100110100011 1") print ("Actual: ", "pad) # test 6: encrypt() print(" 6. Testing encrypt(") plain = "IdLoveToStayHereAndBeNormalBut ItsJust Sooverrated" encrypted - encryption.encrypt (plain, (1,0,1,0,0,1,0,0,1,0), 8) decrypted = encryption.encrypt (encrypted, [1,0,1,0,0,1,0,0,1,0], 8) print ("Input: ", decrypted) print ("Expected: F2n9UB15BPGNMmlsypLMADHzuvTjGk4YD8G+961MMA24qX") print ("Actual: ", encrypted) print("Decrypted:", decrypted, " ")| # binary to decimal conversion # Gauthor mhatcher 2020 # DO NOT CHANGE ANY CODE IN THIS FILE # DO NOT SUBMIT THIS FILE WITH YOUR ASSIGNMENT # converts decimal to a binary list of at least n digits def decToBin (x, n = 6): binary = [] while (x > 0): binary.append(o if x 2 == 0 else 1) x = int(x / 2) while (len (binary) <>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

When it is good, what is different?

Answered: 1 week ago

Question

Write (4y) without exponents. %3D Fill in the blanks.

Answered: 1 week ago