Answer to Question #291645 in Python for Vindu

Question #291645

A company wants to transmit data over the telephone, but it is concerned that its phones may be tapped. All of its data are transmitted as four-digit integers. It has asked you to write a program that will encrypt its data so that the data may be transmitted more securely. Your script should read a four-digit integer entered by the user in a prompt dialog and encrypt it as follows: Replace each digit by (the sum of that digit plus 7) modulus 10. Then swap the first digit with the third, and swap the second digit with the fourth. Then build the script that displays the encrypted integer.

1
Expert's answer
2022-01-28T10:33:07-0500
# Python 3.9.5

def encryption_number(number):
    enc_num = ''
    for i in str(number):
        enc_dig = (int(i) + 7) % 10
        enc_num += str(enc_dig)
    enc_num = enc_num[2] + enc_num[3] + enc_num[0] + enc_num[1]
    return enc_num


def main():
    number = 1234
    print(encryption_number(number))


if __name__ == '__main__':
    main()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS