I'm looking for a neat algorithm, which is capable of encrypting an integer to another integer and decrypting it again AND is secure.
When I was in university, my professor showed me an awesome way to encrypt and decrypt integers using the modular multiplicative inverse combined with the extended euclidian algorithm. We then combined it with a base base10 to base16 conversion to make it shorter.
Now I wanted to use that algorithm again and tried to reproduce it for a whole day, but simply can't remember and/or figure it out again. I tried using Google for research, but haven't found anything usable, or let's say only non-understandable stuff for a math noob like me.
So, what I'm looking for is something like this:
n = 12345678 // number to encrypt, whereas 0 < n < 16^6 k = ???????? m = ???????? // I can't remember the exact calculation, // but if I'm not too mistaken, it should // look very similar to this i = n * k % m // 1 - 8 digits r = base10to16(i) // 1 - 6 letters // Now it should be possible to decrypt it // again... and that's where I'm stuck, // because everything I tried didn't result // in the expected result (12345678), which // may also be due to a wrong calculation in // the first step...
Can someone lead a total math noob to the right directions? Some easy-to-understand online lectures would be nice as well.