Maple's isprime function uses such methods. Thus, all we really need is to generate some random numbers of about 100 digits, then take the next prime bigger. We use Maple's rand to create two functions, BigRand and MedRand , which give us random numbers of around 100 digits and less than 90 digits, respectively. If not, we just pick another and try again. Usually, a suitable exponent will be found after only a few tries.
Lets write RSAEncodeNum which encodes a single large number by computing mod n .
The variable encoded contains a list of several large integers. This is our message, suitably encoded and ready for transmission to our recipient, but indecipherable to anyone who doesn't know the the inverse of a modulo n , that is x . BignumToText to convert it back into readable text. We assume here that the data in the file is plain text. Of course, if you anticipate 8-bit data in your input, the number p here will need changing, as well.