Cryptography

closed account (EwkNwA7f)
A company wants to transmit data over the telephone, but is concerned that its phones could be tapped. All of the data are transmitted as four digit integers. The company has asked you to write a program that encrypts it as follows. Replace each digit by (the sum of that digit plus 7) modulus 10. Then, swap the first digit with the third, swap the second digit with the fourth and print the encrypted integer. Write a separate program that inputs as encrypted four digit integer and it to form the original number.

Help me to have a code for this program.
i think loop statement is applicable.
Why don't you try it yourself first.
if you face any problems, we'd be happy to help you out.

if you've already wrote some code, please post it here, and tell us what you believe to be not working.
If they are that concerned, why are they not using quantum key distribution? :P

Anyways, I agree with Rechard3. We are not here to do your homework for you and that's not how you are going to learn. Try it yourself and come back here if it goes all horribly wrong and you get really stuck. Try the task one step at a time:

1) First make sure you program can accept 4 digit integers as input.

2) Make the function to replace each digit by the sum of the digit + 7 mod 10.

3) Make the function to do the swaps

4) Print the new integer

5) You need only apply steps 3 - 1 backwards to get to an original number. ;)
Last edited on
It looks like the instructions tell you exactly what to do step by step.
Topic archived. No new replies allowed.