Javascript RSA Algorithm Demonstration.

Javascript RSA Algorithm Demonstration.    

I created this demonstration of the RSA algorithm for a course that I took about data structures and algorithms. Javascript has some limitations on handling large numbers - I compensated for some of these with the Extended Euclidean and Russian Peasant algorithms, but there are still some problems, depending on the choice of P and Q. The defaults values work. For more information on the RSA algorithm, follow the links at the end of the page.

Step 1:

Select two numbers which have no common factors. Call them P and Q. Since they have no common factors, they are said to be "relatively prime." You can enter your own values for P and Q, or use the default values provided.

 
P
Q
N = P * Q =
M = (P - 1)(Q - 1) =


Step 2:

Select the public key, E to be relatively prime to M.

 
(This button calculates E for the value of M currently shown in the above textfield. Thus if you change M by typing in a new value after calculating it for the P and Q you entered, that change will be reflected here.)
E =


Step 3:

Select the private key, D, so that (D * E) % M = 1.

 
(This button calculates D for the values of E and M which are currently showing in the textfields above. Thus if you change E or M by typing in a new value, that change will be reflected here.)
D =


Step 4:

Encrypt and Decrypt your message. The message must be an integer with a magnitude less than (N-1).


Message B =
Encrypted message C =
Message C =
Decrypted message B =

0 comments:

Post a Comment