RSA // Cryptography Simulator
Interactive Tool

RSA Algorithm Simulator

Explore public-key cryptography hands-on. Generate real RSA keys, encrypt messages, and decrypt ciphertext — with every mathematical step explained.

✓ Key Generation Modular Arithmetic Encrypt & Decrypt Step-by-step Log
Advertisement
1
Key Setup
2
Generate Keys
3
Encrypt
4
Decrypt
Step 1 — Choose Two Prime Numbers
RSA begins with two distinct large prime numbers p and q. Their product n = p × q forms the modulus used in both keys. For this simulator, use small primes to observe the math clearly.
RSA Theory & Mathematics

RSA (Rivest–Shamir–Adleman) is a public-key cryptosystem invented in 1977. It relies on the practical difficulty of factoring the product of two large prime numbers — the "factoring problem".

RSA uses a key pair: a public key shared openly for encryption, and a private key kept secret for decryption. Anyone can encrypt a message to you; only you can decrypt it.

Core: c = mᵉ mod n (encrypt) m = cᵈ mod n (decrypt)

In real-world usage, key sizes of 2048–4096 bits are standard. This simulator uses small primes so every calculation step is human-readable.

1. Choose two distinct large primes p and q.

n = p × q (modulus)

2. Compute Euler's totient:

φ(n) = (p − 1) × (q − 1)

3. Choose public exponent e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1. Common choice: e = 65537.

4. Compute private exponent d as the modular inverse of e:

d ≡ e⁻¹ (mod φ(n)) so that e × d ≡ 1 (mod φ(n))

To encrypt message m (as an integer with 0 ≤ m < n) using the public key (e, n):

c = mᵉ mod n

Fast exponentiation (square-and-multiply) makes this efficient even for huge exponents. The ciphertext c is the result.

For text, each character is first converted to its ASCII value, then encrypted individually.

To decrypt ciphertext c using the private key (d, n):

m = cᵈ mod n

This works because of Euler's theorem: raising c to the power d modulo n reverses the encryption, recovering the original m.

mᵉᵈ ≡ m (mod n) since ed ≡ 1 (mod φ(n))

RSA security relies on the integer factorization problem: given n, finding p and q is computationally infeasible for large enough n.

With a 2048-bit modulus, the best known algorithms would take longer than the age of the universe to factor n on current hardware.

Common weaknesses to avoid:

• Small primes (as used here) are insecure — easily factored.
• Padding schemes (OAEP) must be used in practice.
• Side-channel attacks target implementation, not the math.
• Quantum computers (Shor's algorithm) can break RSA — post-quantum cryptography is being standardised.

Developed By

Our Student Developers

This RSA simulator was built and contributed to by the following talented students.

01Bishal ADHIKARI
02Saharsha BASNET
03Pema LAMA
04Jenisha SHRESTHA
05Heman SHRESTHA
06Bikram KARKI
07Sulav SUBEDI
08Janet Jeserem CHERONO
09Dhan Bahadur SARU
10Babi GIRI
11Ram Narayan SAH
12Reden ZAPANTA
13Love THAPA
14Kiran SHRESTHA
15Rishan TAMRAKAR
16Gagan Singh THAKURI
17Lekh Bahadur THAPA
18Manish ADHIKARI
19Shikhar PUN
20Amrit SYANGTAN
21Karan Singh SITAULA
22Narayan KHATTRI
23Nimkant BISTA
24Suman CHHETRI
25Jasmine KARKI
26Avishek BASNET
27Rafael OLIVEIRA DE MAGALHAES
28Suman TAMANG
29Saksham DHAMALA
30Utsav KHAREL
31Liza SHRESTHA
32Suman KC
33Amrit GIRI
34Sagar BHANDARI
🎓
Special Thanks & Gratitude
Dr. Pritam Gajkumar Shah
Supervisor & Academic Mentor

With heartfelt gratitude, the development team sincerely thanks Dr. Pritam Gajkumar Shah for his invaluable guidance, expert supervision, and continuous encouragement throughout this project. His dedication to teaching cryptography and computer science has inspired every student on this team.