RSA Encryption Demo
Classroom RSA Keys
Public Key:
Public Key:
e = 7
n = 187
Private Key:
d = 23
n = 187
RSA Encryption
RSA is famous for its security and uses mathematical operations based on exponents and modular arithmetic.
→ Uses two keys: Public Key to Encrypt and Private Key to Decrypt.
→ RSA begins with two prime numbers. A prime number is a natural number greater than 1 that has only two factors: 1 and itself.
For this classroom example:
p = 11, q = 17, so N = 11 × 17 = 187.
The (public key) which is used as exponent is e = 7 and the (private key) used as exponent is d = 23
We have:
Prime number: p=11
Prime number: q=17
N = p*q = 11*17 = 187
p = 11, q = 17, so N = 11 × 17 = 187.
The (public key) which is used as exponent is e = 7 and the (private key) used as exponent is d = 23
We have:
Prime number: p=11
Prime number: q=17
N = p*q = 11*17 = 187
Encrypt
encrypted = messagee mod N
The Public Key is used as the exponent. mod N means take the remainder after dividing by N.
Decrypt
message = encryptedd mod N
The Private Key is used as the exponent. mod N again means take the remainder after dividing by N.
Example: Encrypt "Hello" and Decrypt Cyphertext
Public Key: e = 7
Private Key: d = 23
N = 187
Private Key: d = 23
N = 187
| A | B | C | D | E | F | G | H | K | L | M | N | O | P | R | S | T | U | V | W | X | Y | Space |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
Hello = 8 5 10 10 13
Encrypt:
H = (87) mod 187 = 134
E = (57) mod 187 = 146
L = (107) mod 187 = 175
L = (107) mod 187 = 175
O = (137) mod 187 = 106
Hello encrypted: 134 | 146 | 175 | 175 | 106
Decrypt:
Cipher text: 134 | 146 | 175 | 175 | 106
134 = (13423) mod 187 = 8
→ H
146 = (14623) mod 187 = 5
→ E
175 = (17523) mod 187 = 10
→ L
175 = (17523) mod 187 = 10
→ L
106 = (10623) mod 187 = 13
→ O
Decrypted: Hello
