Question: Here's one python question. Please show your works by coding in your python program? We can refer to the classwork below:) Thanks a lot. Homework

Here's one python question. Please show your works by coding in your python program? We can refer to the classwork below:) Thanks a lot.

Homework 3. Vigenre Cipher The Vigenre cipher is a generalized Caesar cipher. Each letter in a word can have a different shift, depending on the corresponding letter in a key. Suppose we want to encrypt the airport code "LAX", and the encryption key is "dog". The first letter "L" in the airport code will use the first letter of the key, "D", to get the encrypted letter. Since the index of "D" in the reference string "ABCDEF..." is 3 , we make 3 shifts from "L" to get "O", as we did with Cesar cipher in the classwork. Vigenre cipher allows us to use different shifts for each letter. The number of shifts for the next letter, "A" in "LAX", will depend on "O", the second letter in the key "dog", and so forth. Write a Python program to encrypt airport codes (e.g., HKG) using the Vigenre cipher: 1) Ask the user to input a three-letter airport code and a three-letter key. 2) Encrypt the airport code based on the Vigenre cipher rule and display it. The program should be capable of the following. Enter a 3-letter airport code: LAX Enter a 3-letter key: dog LAX is encrypted to OOD. Follow the same submission requirement (.py file and screenshot) as before. Hint: The number of shifts is the index of the corresponding key in the reference string. If the key is "DDD", it will resemble the classwork example. Enter a 3-letter airport code: LAX Enter a 3-letter key: DDD LAX is encrypted to ODA. If the key is "AAA", you are making zero shift for every letter - not really encrypting. Enter a 3-letter airport code: LAX Enter a 3-letter key: A AA LAX is encrypted to LAX. You can recycle most scripts from the classwork. LAX is encrypted to ODA. =RESTART: C:/Users/qwang526/Desktop/10 meek3inclass.py = Here is a random lotter: "I Pick one letter from A.Z: r R is the 18th letter in the alphabet. Here is a random 2-letter \& 2-digit password: 10102 Enter a 3-letter airport code: LAX Shifts? 50 LAX is encrypted to JVV. = RESTART: C:/Users/qwang526/Desktop/W0_week3inclass.py = Here is a random letter: Y Pick one letter from A.Z: w W is the 23 th letter in the alphabet. Here is a random 2-letter \& 2-digit password: YUOI Enter a 3-letter airport code: bis Shifts? 3 BTS is encrypted to ENV. fle Edit Tormat fun Options Wintow Help HCWl Hstudent ID: \#name: ref = "ABCDEFGHIJKLNOPURSTUWXYZ" Hstep I word = inpur ("Enter a 3-1etter airpost code: "). strip(). upper() shift = eval (input("Shifts? ")) \# can use int letter0 = reff [( ref. find ( nord 0])+ shift )426] letter| = ref ( ref. find(word ])+ shift )26 letter2 =ref[( ref. find(nord 2])+ shift )&26] encryptedlord = letter0+letterl+letter2 print( f(nord) is encrypted to leneryptedWord). ")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
