RSA Calculator

This module demonstrates step-by-step encryption with the RSA Algorithm to ensure authenticity of message. The sender encrypt the message with its private key and the receiver decrypt with the sender's public key.

No provisions are made for high precision arithmetic, nor have the algorithms been encoded for efficiency when dealing with large numbers.

Step 1. Calculate N which is a product of two distinct prime numbers p and q

Step 2. Find θ(N) which is (p-1) * (q-1)

Step 3. Select e such that gcd(θ(N),e) = 1 and 1 < e < θ(N)

Step 4. Calculate d such that d*e mod(θ(N) = 1

Step 5. Set public key and private key

Step 6. Enter plaintext message M to encrypt such that M < N ( C = M d (mod n) )

This module is only for data encryption for authenticity. To ensure confidentiality, the plaintext should be encrypted with receiver's public key and decrpted with reciver's private key

To ensure both authenticity and confidentiality, the plainText is first encrypted with private key of sender then the resulting cipherText is encrypted again with public key of receiver.
Decryption starts with private key of receiver and the original message is obtained by decrypting with sender public key

Disclaimer: The program is written in JavaScript and most implementations seem to handle numbers of up to 16 digits correctly.