# Very Basic Encrypt/Decrypt

This topic is 5457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
14%10 = 4
4%10 = 4

its inposible to decrypt

##### Share on other sites
Quote:
 Original post by mike2502514%10 = 44%10 = 4its inposible to decrypt
No it isn't, because in this case you have a 1-1 mapping of input to output.
It sounds like homework though, so I won't solve it for you.

##### Share on other sites
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.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 22
• 17
• 46