Purpose of the page is to demonstrate how RSA algorithm works - generates keys, encrypts message and decrypts it.
See the related blog post for more explanation.
See the related blog post for more explanation.
Enter two prime numbers below (P, Q), then press calculate:
P:
Q:
Variable | Value | Name | Formula | Description |
---|---|---|---|---|
N | modulus | N: P * Q | Product of 2 prime numbers | |
L | length | L: (p - 1) * (q - 1) | Another way of calculating 'L' is to list of numbers from 1 to N, remove numbers which have common factor which N and count the remaining numbers. | |
E | encryption key | Find a number between 1 and L that is coprime with L and N. | ||
D | decryption key | D * E mod L = 1 | Remainder of the product of D and E when divided by L should be 1 (D * E % L = 1) |
Enter a message to encrypt:
Message converted to ASCII code:
Encrypted message: message^E % N (PowerMod can be used to calculate this very fast. Formula is applied on ASCII code of each character.)
Enter a encrypted message (cipher):
Message decrypted to ASCII code:
Decrypted Message: encrypted_message^D % N (PowerMod can be used to calculate this very fast. Formula is applied on ASCII code of each character.)