1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
2
Rep Power
0

#### Simple Java Decryption

Create an application that should read a four-digit 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 four-digit 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.
2. 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.
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
2
Rep Power
0
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.
4. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2010
Posts
42
Rep Power
4
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 -> (8-7), X, Y, Z

By writing an example out like this, you should be able to see how to calculate the last 3 digits.