Completed checkpoint 2

Created a function that encrypts a message (taken
as a parameter) by adding a secret number (defined
globally?) to each digit.
This commit is contained in:
Cory 2024-05-07 12:27:13 -04:00
parent 09fd746bbc
commit 64cb255e0a
1 changed files with 10 additions and 1 deletions

View File

@ -24,4 +24,13 @@ def numerify(message):
for item in message: for item in message:
hex_values.append(item.encode()[0]) hex_values.append(item.encode()[0])
return hex_values return hex_values
print(numerify('abc')) print(numerify('abc'))
# Checkpoint 2
secret_number = 1
def encrypt(numeric_message):
to_encrypt = []
for item in numerify(numeric_message):
to_encrypt.append((item + secret_number) % 256)
return to_encrypt
print(encrypt('abc'))