This is a fully browser-based web application that demonstrates the RSA encryption/decryption process. It uses the Square and Multiply algorithm for efficient modular exponentiation and is designed as an educational tool.
Live Demo: [Link to your GitHub Pages URL]
- HTML5
- CSS3
- Vanilla JavaScript (with BigInt for large number arithmetic)
- RSA Key Generation: Input two primes
pandqto generate a public/private key pair. - Encryption/Decryption: Encrypt a numeric message with the public key and decrypt it with the private key.
- Square and Multiply: The application uses and displays the step-by-step process of the Square and Multiply algorithm for all exponentiation operations.
- Input Validation: Ensures that inputs are prime and that messages are valid.
- No Backend: All computations are performed in the client's browser.
To run this project locally:
- Clone the repository:
git clone https://github.com/<your-username>/<your-repo-name>.git - Navigate to the project directory:
cd <your-repo-name> - Open the
index.htmlfile in your web browser.
The Square and Multiply algorithm (also known as binary exponentiation) is used to compute b^e mod m efficiently. Instead of performing e-1 multiplications, it reduces the complexity significantly.
The algorithm works by processing the bits of the exponent e from left to right.
- Start with a result of 1.
- For each bit in the binary representation of
e: a. Square the current result:result = (result * result) mod m. b. If the bit is 1, multiply the result by the base:result = (result * b) mod m. - After iterating through all bits, the final result is the answer.
This implementation uses JavaScript's native BigInt to handle the large numbers that are common in RSA.