I need to implement RSA algorithm in Java. I've found the best solution using BigIntegers, problem is that I need to work only with ints or longs.
The encrypting is done like this: M[i]^e mod n
where M[i] is an input char and e is a key value. I tried using the ASCII codes of chars, and with codes such as 115 and 116 I quickly get out of range. How can I solve the problem? Thanks in advance.
You may have a look at modular exponentiation. This way you overcome most of the overflows in your calculations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With