Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON!!!! PLEASE HELP USING PYTHON CODE!!!!!! Revise the substitutionEncrypt function from section 3.5 (p. 102) of the textbook to (1) remove all spaces from the

PYTHON!!!! PLEASE HELP USING PYTHON CODE!!!!!!

Revise the substitutionEncrypt function from section 3.5 (p. 102) of the textbook to (1) remove all spaces from the plaintext message before it is encrypted and (2) generate the substitution cipher key from a password. (substitutionEncrypt will call genKeyFromPass to do this.) The password should be a parameter, psw, which will replace key as a parameter in the function header. (CODE IMAGES BELOW)

Write function substitutionDecrypt, which will have two parameters, cipherText, a string, a message encrypted by substitutionEncrypt, and psw, the password used to generate the encryption key, also a string. substitutionDecrypt should return the original plaintext message with spaces removed (a string). Finally, write a top-level function, main. main should (a) use Pythons built-in input function to get a string to encrypt and a password; (b) call substitutionEncrypt to encrypt the password; (c) print the value returned by substitutionEncrypt; (d) call substitutionDecrypt to convert the value returned by substitutionEncrypt back to plaintext; (e) print the value returned by substitutionDecrypt. Note that substitutionEncrypt and substitutionDecrypt will need to call genKeyFromPass, which calls removeDupes and removeMatches. Starter code for genKeyFromPass, removeDupes, and removeMatches is in the text (p. 106-107); you will need to write a docstring for each function.image text in transcribedimage text in transcribedimage text in transcribed

3.6 Creating a Key 107 removeMatches (myString, removeString): newStr = "" for ch in myString: def if ch not in removeString: newStr = newStr + ch return newStr Listing 39 Remove the characters in one string from another >>>removeDupes 'topsecret') topsecr >removeMatches ('abcdefghijklmnopqrstuvuxyz', 'topsecr') abdfghijklmnquvwxyz ' >>> removeMatches ('abcdefghijklmnopqrstuvuxyz',removeDupes 'bondjamesbond') 'cfghiklpgrtuvwxyz' Session 3.11 Testing removeDupes and removeMatches Now that we have implemented removeDupes and removeMatches, the rest of our alphabet scrambling algorithm is fairly easy. Listing 3.10 shows the Python code needed to provide a scrambled version of the alphabet using a password as the starting point def genKeyFromPass (password) key = 'abcdefghijklmnopqrstuvwxyz' password = removeDupes(password) lastChar password [-1] last!dx = key, find (1astChar) afterString renoveMatches (key[1astlax+1:) ,password) beforeString - removeMatches (key [: lastIdx],password) key = password + afterString + beforeString return key Listing 3.10 Generating a key starting from a password

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

1. Communicating courses and programs to employees.

Answered: 1 week ago

Question

6. Testing equipment that will be used in instruction.

Answered: 1 week ago