Demo

Follow the steps to generate RSA keys.

Rotate Device

Please rotate your device for a better experience.

Key Icon
Key Icon
Key Icon
Key Icon

Prime Numbers

Prime numbers are fundamental to the RSA encryption process. A prime number \( p \) is a natural number greater than 1 that has no positive divisors other than 1 and itself. In RSA, two distinct prime numbers \( p \) and \( q \) are selected. These primes are used to generate the modulus \( n \) as follows: \[ n = p \times q \] The security of RSA relies on the difficulty of factoring this large number \( n \) back into its prime factors \( p \) and \( q \).

Modulus (n)

The modulus \( n \) is the product of the two selected prime numbers \( p \) and \( q \): \[ n = p \times q \] It is a crucial component in both the public and private keys. The security of RSA encryption depends on the difficulty of factoring \( n \) into its prime factors \( p \) and \( q \).

Euler's Totient Function (φ(n))

Euler's Totient Function, denoted as \( \varphi(n) \), is used in RSA to calculate the private exponent. For the product of two primes \( p \) and \( q \), \( \varphi(n) \) is given by: \[ \varphi(n) = (p-1) \times (q-1) \] \( \varphi(n) \) represents the number of integers less than \( n \) that are coprime with \( n \). It is used to ensure that the encryption and decryption keys are correctly aligned.

Public Exponent (e)

The public exponent \( e \) is a part of the RSA public key. It is chosen such that: \[ 1 < e < \varphi(n) \] and \( e \) is coprime with \( \varphi(n) \) (i.e., \( \gcd(e, \varphi(n)) = 1 \)). The public exponent is used in the encryption process to transform the plaintext into ciphertext.

Private Exponent (d)

The private exponent \( d \) is a part of the RSA private key. It is calculated as the modular multiplicative inverse of \( e \) modulo \( \varphi(n) \): \[ d \times e \equiv 1 \ (\text{mod} \ \varphi(n)) \] This relationship ensures that the decryption process correctly recovers the original plaintext message.

Message Encryption

Message encryption in RSA involves converting a plaintext message \( M \) into ciphertext \( C \) using the recipient's public key \( (n, e) \). The encryption is performed using the formula: \[ C = M^e \ (\text{mod} \ n) \] This process ensures that the message can be securely transmitted, as only the intended recipient can decrypt it using their private key.

Message Decryption

Message decryption in RSA is the process of converting the ciphertext \( C \) back into the original plaintext message \( M \) using the private key \( (n, d) \). The decryption is performed using the formula: \[ M = C^d \ (\text{mod} \ n) \] This ensures that only the intended recipient, who possesses the private key, can successfully decrypt and recover the original message.

Practice

Follow the steps to generate RSA keys.

Prime Numbers

Prime numbers are fundamental to the RSA encryption process. A prime number \( p \) is a natural number greater than 1 that has no positive divisors other than 1 and itself. In RSA, two distinct prime numbers \( p \) and \( q \) are selected. These primes are used to generate the modulus \( n \) as follows: \[ n = p \times q \] The security of RSA relies on the difficulty of factoring this large number \( n \) back into its prime factors \( p \) and \( q \).


Modulus (n)

The modulus \( n \) is the product of the two selected prime numbers \( p \) and \( q \): \[ n = p \times q \] It is a crucial component in both the public and private keys. The security of RSA encryption depends on the difficulty of factoring \( n \) into its prime factors \( p \) and \( q \).


Euler's Totient Function (φ(n))

Euler's Totient Function, denoted as \( \varphi(n) \), is used in RSA to calculate the private exponent. For the product of two primes \( p \) and \( q \), \( \varphi(n) \) is given by: \[ \varphi(n) = (p-1) \times (q-1) \] \( \varphi(n) \) represents the number of integers less than \( n \) that are coprime with \( n \). It is used to ensure that the encryption and decryption keys are correctly aligned.


Public Exponent (e)

The public exponent \( e \) is a part of the RSA public key. It is chosen such that: \[ 1 < e < \varphi(n) \] and \( e \) is coprime with \( \varphi(n) \) (i.e., \( \gcd(e, \varphi(n)) = 1 \)). The public exponent is used in the encryption process to transform the plaintext into ciphertext.


Private Exponent (d)

The private exponent \( d \) is a part of the RSA private key. It is calculated as the modular multiplicative inverse of \( e \) modulo \( \varphi(n) \): \[ d \times e \equiv 1 \ (\text{mod} \ \varphi(n)) \] This relationship ensures that the decryption process correctly recovers the original plaintext message.


Message Encryption

Message encryption in RSA involves converting a plaintext message \( M \) into ciphertext \( C \) using the recipient's public key \( (n, e) \). The encryption is performed using the formula: \[ C = M^e \ (\text{mod} \ n) \] This process ensures that the message can be securely transmitted, as only the intended recipient can decrypt it using their private key.


Message Decryption

Message decryption in RSA is the process of converting the ciphertext \( C \) back into the original plaintext message \( M \) using the private key \( (n, d) \). The decryption is performed using the formula: \[ M = C^d \ (\text{mod} \ n) \] This ensures that only the intended recipient, who possesses the private key, can successfully decrypt and recover the original message.