University of Phoenix CYB CYB 135 Computer ScienceEngineering & TechnologyPython Programming
University of Phoenix CYB CYB 135 Computer ScienceEngineering & TechnologyPython Programming Question Answered step-by-step How do I get this code to fail and give me the following message?: Key = 99 Error: Key is not Found! I am given the following, and need to fill in anything with a #TODO: #Caesar Cipher Encryption function def caesar_cipher_encrypt(text, key, a): text = () encrypted_Text = "" for i in text: if i in a: index = ((i) + key) % len(a) encrypted_Text = encrypted_Text + a[index] else: encrypted_Text = encrypted_Text + i return encrypted_Text #Caesar Cipher Decrypt function def caesar_cipher_decrypt(text, key, a): text = () decrypted_Text = "" for i in text: if i in a: index = ((i) - key) % len(a) decrypted_Text = decrypted_Text + a[index] else: decrypted_Text = decrypted_Text + i return decrypted_Text # TODO - Write a function called caesar_hack( text, a, check ) that takes a Caesar Cipher encrypted message, an alphabet list, and the original message in main. # This function will attempt to hack an encrypted message. Use a nested for loop to find the key between 0 & 25. # Check where the letter is found in the alphabet list based on the encrypted text letter sent to this function. # Check if the decrypted message is the same as the original message. # If a key is found , return the key value and the decrypted message. # If not found return 99 as the key and "Error: Key not found!" as the message. def caesar_hack(text, a, check):
Información del documento
- Subido en
- 4 de septiembre de 2022
- Número de páginas
- 7
- Escrito en
- 2022/2023
- Tipo
- Examen
- Contiene
- Preguntas y respuestas