Very Basic Encrypt/Decrypt
I am doing an exercise from a C++ books, and it says i have to encrypt a number, by getting each digit and replaces it with (the sum of the digit + 7) % 10. Now that works perfect. But I have a hell of a time decrypting. Mainly what in the the world is the opposite of % 10 ?
Please help...thanks.
Quote:Original post by mike25025No it isn't, because in this case you have a 1-1 mapping of input to output.
14%10 = 4
4%10 = 4
its inposible to decrypt
It sounds like homework though, so I won't solve it for you.
If N is your encrypted number, then you can decrypt it with (N + 3) % 10. This is because for any digit n, ((n + 7) + 3) % 10 = n, because n is between 0 and 9.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement