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 = text.upper()
encrypted_Text = ""
for i in text:
if i in a:
index = (a.find(i) + key) % len(a)
encrypted
...[Show More]
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 = text.upper()
encrypted_Text = ""
for i in text:
if i in a:
index = (a.find(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 = text.upper()
decrypted_Text = ""
for i in text:
if i in a:
index = (a.find(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)
[Show Less]