Jump to content
  • Advertisement
Sign in to follow this  
Manish256

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by mike25025
14%10 = 4
4%10 = 4

its 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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!