Untitled
unknown
plain_text
24 days ago
841 B
12
Indexable
Never
def vigenere_cipher(airport_code, key): reference_string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" encrypted_code = "" for i in range(len(airport_code)): letter = airport_code[i] key_letter = key[i] shift = reference_string.index(key_letter) encrypted_letter = reference_string[(reference_string.index(letter) + shift) % 26] encrypted_code += encrypted_letter return encrypted_code # Ask the user to input a three-letter airport code and a three-letter key airport_code = input("Enter a 3-letter airport code: ").upper() key = input("Enter a 3-letter key: ").upper() # Encrypt the airport code based on the Vigenère cipher rule encrypted_code = vigenere_cipher(airport_code, key) # Display the encrypted code print(f"{airport_code} is encrypted to {encrypted_code}.")
Leave a Comment