I am trying to implement RSA in C++ for extremely large numbers. I am not using any library. I wanted to write my own code 🙂 So I have used strings to store these large numbers. Multiplication and division of large numbers is extremely quick so thats not a problem. But when i do encrypting or decrypting i.e using a^b modm this is extremely slow. I used p and q as 50 digits numbers and tried encrypting a text of about 20 characters. It took me one hour to encrypt and decrypt. I used exponentiation by squaring method to reduce the computational time. What possible improvement can i do?
Also what is the best way to generate primes p & q.(Preferably industry standard)
Are you doing the modular reduction after after squaring/multiplication during your exponentiation? You should calculate the modulus after each squaring/multiplication so the intermediate results should never be more than twice the digits as in your value for m.