Completed checkpoint 3

Created a function that decrypts by adding (256 -
secret number) and moduloing 256.
This commit is contained in:
Cory 2024-05-07 12:54:32 -04:00
parent 64cb255e0a
commit f5f3335453
1 changed files with 10 additions and 2 deletions

View File

@ -30,7 +30,15 @@ print(numerify('abc'))
secret_number = 1
def encrypt(numeric_message):
to_encrypt = []
for item in numerify(numeric_message):
for item in numeric_message:
to_encrypt.append((item + secret_number) % 256)
return to_encrypt
print(encrypt('abc'))
print(encrypt(numerify('abc')))
# Checkpoint 3
def decrypt(numeric_message):
to_decrypt = []
for item in numeric_message:
to_decrypt.append((item + (256 - secret_number)) % 256)
return to_decrypt
print(decrypt(encrypt(numerify('abc'))))