I am implementing the RSA algorithm for encryption and decryption as given here:
http://www.di-mgt.com.au/rsa_alg.html
But could not understand the random pr
I don't have the answer, but if the same code compiled with two different compilers gives different answers I would guess that some of the types are of different size or you are implicitly relying on undefined behaviour somewhere.
The first thing you should do is, given the same prime number pairs, check that all the constants you generate come out the same in both implementations. If not, your key pair generation algorithms are at fault.
The next thing is to make sure that your input data for encryption is absolutely identical on both systems. Pay particular attention to how you deal with end of line characters. Bear in mind that, on Windows, end of line is \r\n
and on Linux it is \n
. Most Windows library implementations will convert \r\n
to \n
as the file is read in if "r"
is supplied as the mode parameter to fopen()
. Your implementation might be different.
Finally, whatever the problem is, on no account ever use gets()
If you even catch yourself thinking about using it again, you should remove the frontal lobes of your brain with an ice pick.