The RSA Algorithm

The following box displays the RSA algorithm. The receiver creates two keys:-
Enter two distinct prime numbers (p & q):-

The product, N, of p and q is:-
N =
With each decreased by 1 their product P becomes:-
P =
Enter (optional) two numbers D & E:-
E = (should not share a factor with P)
D = (D*E should be 1 more than some multiple of P)


The sender now enters the message
(a number M less than N to be encoded and sent to the receiver):-
M =
The sender uses the encryption, C = M^E mod N, to yield the code C as:-
C =

You, as receiver, use the decryption, M = C^D mod N, to retrieve the message M:-
M =

Remarks:- Exercise. Modify the interface to allow the message to be a string of letters of the alphabet. [Represent each letter of the alphabet by an integer from 1 to 26; then encrypt the letters separately.]

Exercise. Repeat the preceding exercise, but represent each block of two letters as an integer.

Further exploration of RSA:-

Document: © 1998 D.R. Watson
Last update: