November 23rd, 2012, 12:52 PM

Simple Java Decryption
Hi guys, please read the following:
Create an application that should read a fourdigit integer entered by the user and encrypt as follows: Replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. Then swap the first digit with the third, and swap the second with the fourth. Then print the encrypted integer. Write a separate application that inputs an encrypted fourdigit integer and decrypts it (by reversing the encryption scheme) to form the original number.
The bolded text is where I'm stuck at. How do you reverse remainder calculations? Please provide as simple a solution as possible. Thanks.
November 23rd, 2012, 04:58 PM

Have you worked out the first part yet?
Have you tried working through the second part on a piece of paper so you see the steps that must be done.
November 23rd, 2012, 05:39 PM

Originally Posted by NormR
Have you worked out the first part yet?
Have you tried working through the second part on a piece of paper so you see the steps that must be done.
Hi NormR, thanks for your reply. I did the first part by myself already. I'd have tried the second part but have no clue whatsoever as to how to get an original value back from a modulus calculation. Please note this is not homework but rather my own leisure studies.
November 23rd, 2012, 06:04 PM

Originally Posted by jjb1989
Hi NormR, thanks for your reply. I did the first part by myself already. I'd have tried the second part but have no clue whatsoever as to how to get an original value back from a modulus calculation. Please note this is not homework but rather my own leisure studies.
1357 > 8, 10, 12, 14 > 8024 > 2480
2480 > 8024 > (87), X, Y, Z
By writing an example out like this, you should be able to see how to calculate the last 3 digits.