To do RSA examples, you need to pick distinct primes p and q. Enter a number m < 1,000,000,000 in the following web form. If m is prime, you will be told; if not, you will be given back the least prime factor of m.

Enter m:

Once you have p, q and n = pq, you need to pick an encryption exponent e, and solve for the decryption exponent d. The main thing is that gcd(e, phi(n)) must be 1, where phi(n) = (p-1)(q-1). The next web form will be useful for this. It computes gcf(a, b) and writes it as a linear combination of a and b. So let a = (p-1)(q-1), and keep picking b at random until you get one where gcd(a, b) = 1. Then the y in the solution ax + by = 1 that it gives is your d. (If y < 0, use d = (p-1)(q-1) + y, instead to get a positive value for d.)


Enter a:

Enter b:

The RSA crypto system involves computing powers mod n. Given a piece of data i, to encrypt it, compute ie mod n. To recover i from the encrypted value j, compute jd. Here is a web form to do such computations: Just plug in the variables m, n and a, and you will get back the value of ma (mod n).


Enter m:

Enter a:

Enter n: