Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSA encryption algorithm in Java: no BigIntegers

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.

like image 247
Egor Avatar asked May 21 '11 07:05

Egor


1 Answers

You may have a look at modular exponentiation. This way you overcome most of the overflows in your calculations.

like image 64
Howard Avatar answered Nov 15 '22 04:11

Howard