Question: Write the below substitution cipher using python3 Substitution Cipher example, if key is: bpzhgocvjdqswkimlutneryaxf, a string face will be decoded to obzg. Specific requirements are:

Write the below substitution cipher using python3

Substitution Cipher example, if key is: bpzhgocvjdqswkimlutneryaxf, a string face will be decoded to obzg.

Specific requirements are:

(1) Write a function substitutionEncrypt that takes a plaintext and a key (the default key is bpzhgocvjdqswkimlutneryaxf) to generate a ciphertext.

(2) Write a function keyGen that randomly generates a key.

(3) Write a testDrive (or main) function that takes a key code and an arbitrary number of strings, generate ciphertext for each string, and print out the key used, original and its ciphertext one by one. If (an empty string) is provided as the keyCode, then the default key will be used, otherwise, assuming the keyode is a non-empty string (e.g. R for random generation) a key is randomly generated.

Test the following cases:

Test 1: keycode is , two strings face and blow

Note: it will print out something like the following

Key: bpzhgocvjdqswkimlutneryaxf

face -> obzg, blow -> psiy

Test 2: same as Test 1 except keycode = r, i.e. key generated by keyGen

Test 3: key is , four strings wonderful, python, java, doedlugvusu

Test 4: Same as Test 3 except keycode = r, i.e. key generated by keyGen.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!