Search for a tool
RSA Cipher

Tool to decrypt/encrypt with RSA cipher. RSA is an asymmetric algorithm for public key cryptography created by Ron Rivest, Adi Shamir and Len Adleman. It is the most used in data exchange over the Internet.

Results

RSA Cipher -

Tag(s) : Modern Cryptography, Arithmetics

Share
Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best 'RSA Cipher' tool for free! Thank you!

RSA Cipher

RSA Decoder

Indicate known numbers, leave remaining cells empty.












RSA Certificate Reader



Complementary Helper tools

Calculate P and Q from public key N

Calculate N by multiplying P*Q

⮞ Go to: Multiplication

Calculate Phi φ(N) by multiplying (P-1)*(Q-1)

⮞ Go to: Multiplication

Calculate D the modular inverse e^-1 mod φ(N)

Prime Number Generation

⮞ Go to: Prime Numbers Search

Calculate Modular Exponentiation A^B mod N

Convert to Integer Number (Base 10 Decimal)

From an Hexadecimal value (Base 16)

⮞ Go to: Hexadecimal (Base 16)

From Base64 encoded string

⮞ Go to: Base64 Coding

From a file (binary data)

⮞ Go to: File Creation

Answers to Questions (FAQ)

What is RSA encryption? (Definition)

RSA (named after its creators Ronald Rivest, Adi Shamir and Leonard Adleman) is an asymmetric cryptographic algorithm based on modular arithmetic and the difficulty of factoring a large integer $ n $, which is the product of two distinct large prime numbers. Using a public key and a private key, RSA can be used for both encryption and digital signatures.

How to encrypt using RSA?

RSA encryption is based on a mathematical operation applied to an integer representing the message. In its simplified mathematical form, with the public key $ (n,e) $, the message $ M $ is encrypted as $$ C \equiv M^e \pmod n $$

This operation requires $ M < n $. In practice, it is not used alone to encrypt a message directly: a padding scheme, such as RSAES-OAEP, first transforms the message into a representation suitable for encryption.

Example: Encrypt the message R,S,A, encoded in ASCII as the hexadecimal value 0x525341, i.e. 5395265 in decimal, with the public key $ n = 6199931 $ and $ e = 101 $, i.e. $ C = 5395265^{101} \mod 6199931 = 4331034 $. The encrypted message is therefore 4331034.

In practice, the maximum message size depends on the padding scheme used. With RSAES-OAEP, the maximum message size is smaller than the size of the modulus $ n $. To encrypt large amounts of data, RSA is generally used in a hybrid encryption scheme: RSA encrypts a symmetric key, which is then used to encrypt the data.

How to decrypt RSA?

RSA decryption requires the private key corresponding to the public key used for encryption. In its simplified mathematical form, the plaintext $ M $ is computed as: $$ M \equiv C^d \pmod n $$ where $ C $ is the ciphertext and $ (n,d) $ are the corresponding private parameters.

Example: Decrypt the message C=4331034 with the public modulus $ n = 6199931 $ and the private exponent $ d = 5029565 $, i.e. $ M = 4331034^{5029565} \mod 6199931 = 5395265 $. 5395265 is the plaintext (i.e. 0x525341 in hexadecimal, corresponding to the letters R,S,A in ASCII).

In practice, this raw number is not necessarily the original message: it may contain encoding or padding that must be removed according to the scheme used.

How to generate RSA keys?

RSA uses a public key (consisting of two numbers $ (n,e) $) and a private key. In its simplified mathematical representation, the private key includes the number $ d $ associated with $ n $. In practice, private keys also contain other parameters, including $ p $ and $ q $.

— Select two distinct prime numbers $ p $ and $ q $, generated randomly and with sufficient size.

— Calculate $ n = p \times q $.

— Calculate Euler's totient function $ \phi(n) = (p-1)(q-1) $.

— Select an integer $ e \in \mathbb{N} $ such that $ 1 < e < \phi(n) $ and $ \operatorname{GCD}(e,\phi(n)) = 1 $.

— Calculate the modular inverse $ d $ of $ e $ modulo $ \phi(n) $, i.e. $ d \equiv e^{-1} \mod \phi(n) $ (using the extended Euclidean algorithm).

With these numbers, the pair $ (n,e) $ constitutes the public key, and the pair $ (n,d) $ represents the private key in the simplified mathematical model.

Example: $ p = 1009 $ and $ q = 1013 $, so $ n = pq = 1022117 $ and $ \phi(n) = 1020096 $. The number $ e = 101 $ is coprime to $ \phi(n) $, and its modular inverse is $ d = 767597 $.

Keys must be generated using sufficiently large prime numbers and a cryptographically secure random number generator. The accidental reuse of the same prime factor in multiple RSA keys, particularly due to a faulty random number generator, can make it possible to recover the factors by computing the GCD of the public moduli.

Using identical values for $ p $ and $ q $ is a very bad idea because factorization becomes trivial: $ n = p^2 $. In this particular case, note that $ \phi(p^2) = p(p-1) $.

How to recognize RSA ciphertext?

Raw RSA ciphertext is generally represented by an integer between $ 0 $ and $ n-1 $, possibly accompanied by key parameters such as $ n $ and $ e $.

In real-world applications, however, data related to RSA can be represented in different forms: binary numbers, hexadecimal numbers, PEM files, ASN.1 structures or Base64-encoded data.

The size of an RSA key is generally expressed in bits and corresponds to the size of the modulus $ n $ (usually 2048 or 3072 bits for currently deployed keys; 1024-bit keys are now considered insufficient).

RSA has notably been used in TLS/HTTPS for certificate signatures and, in older versions of TLS, for key transport. TLS 1.3 no longer supports RSA key transport.

What are the possible attacks against RSA?

Method 1: Prime factorization of $ n $ to find $ p $ and $ q $.

The RSA cipher relies on the difficulty of quickly finding the values of $ p $ and $ q $, which are the prime factors of $ n $. To recover the private key from the public key, an attacker can attempt to factor the number $ n $. Once $ p $ and $ q $ have been recovered, it becomes possible to calculate $ \phi(n) $ and then the private key $ d $. The feasibility of this attack depends notably on the key size and the available computing resources. RSA keys of sufficient size are designed to make this factorization impractical with known classical computing resources.

Method 2: Finding a common factor in several public keys $ n $

Key generation relies on randomly generated prime numbers. However, if the same prime factor $ p $ (or $ q $) is accidentally used in multiple distinct public keys, it can be recovered by computing the GCD of the moduli $ n $. If the GCD of two moduli is greater than 1, it reveals a common prime factor. Dividing each modulus by this factor also reveals the other prime factor.

Method 3: Chosen-ciphertext attack

Given a public key $ (n,e) $ and a known ciphertext $ c \equiv m^e \pmod{n} $, an attacker may attempt to obtain the decryption of another chosen ciphertext $ c' $. Based on the property $ m_1^e m_2^e \equiv (m_1 m_2)^e \pmod{n} $, decrypting a ciphertext $ c' \equiv c \times r^e \pmod{n} $, where $ r $ is a chosen number that is invertible modulo $ n $, can return the value $ m \times r \pmod{n} $. Multiplying the result by $ r^{-1} $ modulo $ n $ then makes it possible to recover $ m $, the original message. This attack concerns implementations that expose a decryption oracle without appropriate protections.

Method 4: Attack on short messages with a small exponent $ e $

With a small exponent ($ e = 3 $) and a sufficiently short message $ m $ (such that $ m < n^{1/e} $), the raw ciphertext $ c = m^e $ is smaller than $ n $. The modulo operation therefore has no effect, and it is possible to recover the message $ m $ by calculating the $ e $-th root of $ c $. This attack concerns raw RSA without padding and does not apply in the same way to correctly implemented encryption schemes.

Method 5: Wiener's attack against private keys $ d $ that are too small

If the private exponent $ d $ is sufficiently small, notably if $ d < \frac{1}{3} n^{\frac{1}{4}} $, and the prime factors are sufficiently close ($ q < p < 2q $), Wiener's attack may recover $ d $ from the public key. It relies on continued fractions to exploit approximations of $ e/n $.

How to decrypt RSA without the private key?

Without the private key, decrypting a properly encrypted RSA message is considered computationally infeasible using known classical computing resources, provided that the key is sufficiently large and the encryption scheme is correctly implemented.

One theoretical approach is to factor the public number $ n $ to recover its two prime factors $ p $ and $ q $. For small values, this operation can be quick with current algorithms and computers. However, factoring RSA moduli of sufficient cryptographic size remains impractical in practice.

Some databases list known factorizations, such as here

Once $ p $ and $ q $ have been recovered, it becomes possible to calculate the private key $ d $ and decrypt the messages.

Why is the number e=65537 used in RSA?

The value $ e=65537 $ represents a compromise between efficiency and security.

An excessively large value of $ e $ increases the time required for encryption and signature verification. An excessively small value can facilitate certain attacks in incorrectly implemented systems, particularly when encryption is performed without appropriate padding.

$ 65537 $ is a Fermat number: $ 65537 = 2^{2^4} + 1 $. Its binary representation contains few bits set to 1, making modular exponentiation efficient.

This value has become the de facto standard for the RSA public exponent. It is widely recommended and should generally not be changed without a specific technical reason.

How to convert a decrypted number into plaintext?

The number obtained after decryption is an integer representing the numerical value of the plaintext content, after any padding has been removed.

Generally, this integer can be converted into a sequence of bytes and then interpreted according to the character encoding used (such as ASCII or UTF-8).

Example: The integer 431164974181 has the hexadecimal representation 64,63,6F,64,65, corresponding to the characters D,C,O,D,E (in ASCII).

In a real-world RSA implementation, the decryption result may contain encoding or padding that must be processed before the original message is obtained.

What is an RSA key or an RSA certificate?

An RSA key is a set of mathematical parameters used to perform encryption or signing operations.

An RSA public key contains, among other things, the values $ n $ and $ e $. An RSA private key contains the values $ n $, $ e $, $ d $, $ p $ and $ q $, as well as other possible parameters.

PEM files are text files containing Base64-encoded data, enclosed by markers indicating their type. Several formats are possible:

— A public key in SubjectPublicKeyInfo format generally begins with -----BEGIN PUBLIC KEY----- and contains the public parameters $ n $ and $ e $.

— An RSA private key in PKCS#1 format begins with -----BEGIN RSA PRIVATE KEY----- and contains the private parameters, including $ n $, $ e $, $ d $, $ p $ and $ q $.

— A private key in PKCS#8 format begins with -----BEGIN PRIVATE KEY----- and can contain an RSA key, among other key types.

An X.509 certificate differs from an RSA key: it contains a public key and information about its owner, as well as a signature used to authenticate its content. The public key contained in an X.509 certificate is not necessarily an RSA key.

Can quantum computers break RSA?

A sufficiently powerful and fault-tolerant quantum computer could efficiently factor large numbers using Shor's algorithm. This would compromise the security of RSA.

However, current quantum computers do not have the capabilities required to factor RSA moduli used in practice. This threat is driving the development and gradual deployment of post-quantum cryptography.

When was RSA invented?

Ronald Rivest, Adi Shamir and Leonard Adleman described the RSA algorithm in 1977. It was subsequently patented in the United States in 1983, and the patent expired in 2000.

Source code

dCode retains ownership of the "RSA Cipher" source code. Any algorithm for the "RSA Cipher" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "RSA Cipher" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "RSA Cipher" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.

Cite dCode

The content of the page "RSA Cipher" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).

Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).

To cite dCode.fr on another website, use the link: https://www.dcode.fr/rsa-cipher

In a scientific article or book, the recommended bibliographic citation is: RSA Cipher on dCode.fr [online website], retrieved on 2026-11-27, https://www.dcode.fr/rsa-cipher

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best 'RSA Cipher' tool for free! Thank you!


https://www.dcode.fr/rsa-cipher
© 2026 dCode — The ultimate collection of tools for games, math, and puzzles.
â–˛  
Feedback