November 23rd, 2012, 11:52 AM
Simple Java Decryption
Hi guys, please read the following:
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.
November 23rd, 2012, 03: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, 04:39 PM
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.
Originally Posted by NormR
November 23rd, 2012, 05:04 PM
1357 -> 8, 10, 12, 14 -> 8024 -> 2480
Originally Posted by jjb1989
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.