A
Alice
Click "Generate Alice's Keys" to create RSA key pair
B
Bob
Click "Generate Bob's Keys" to create RSA key pair
🧮 RSA Algorithm Steps
Step 1: Choose two large prime numbers
Select two distinct prime numbers p and q
Example: p = 61, q = 53
Step 2: Calculate the modulus
n = p × q
Example: n = 61 × 53 = 3233
Step 3: Calculate Euler's totient function
φ(n) = (p-1) × (q-1)
Example: φ(3233) = 60 × 52 = 3120
Step 4: Choose public exponent
Choose e such that gcd(e, φ(n)) = 1
Common choice: e = 65537
Step 5: Calculate private exponent using Extended Euclidean Algorithm
Find d such that e × d ≡ 1 (mod φ(n))
This means: e × d = 1 + k × φ(n) for some integer k
Result: Key Pairs
Public Key: (n, e) - shared with everyone
Private Key: (n, d) - kept secret
🔄 Text Encryption/Decryption Demo
Once both Alice and Bob have generated keys, try encrypting a text message!
Letters will be converted to numbers: A=1, B=2, C=3... Z=26
🎓 Educational Notes:
- Character Encoding: Each letter is converted to a number (A=1, B=2, C=3... Z=26, Space=27)
- Block Processing: Text is divided into blocks that fit within the key size limit (< n)
- Padding: In real implementations, secure padding schemes like OAEP are used
- Practical Use: Real RSA typically encrypts symmetric keys, not direct text messages