Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

8. A company would like to encrypt a token that it uses to identify data. The to

ID: 3586588 • Letter: 8

Question

8. A company would like to encrypt a token that it uses to identify data. The token is a four digit integer. The encryption method is as follows- replace each digit with the result of adding 7 to the digit and getting the remainder by dividing the resulting value by 10. Write a method that will return the answer as a new four digit integer. Now, writea method that will DECRYPT the integer token you just created back to your original four digit integer. Points will be awarded for the correct algorithm as well as the correct method. (20)

Explanation / Answer

def encrypt(token):
y=""
while token!=0:
x=token%10
token=int(token/10)
x=(x+7)%10
y=str(x)+y

y=int(y)
return y

def decrypt(token):
y=""
while token!=0:
x=token%10
token=int(token/10)
x=(x-7+10)%10
y=str(x)+y

y=int(y)
return y

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote