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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started