RSA Asymmetric Encryption Tool | Online Public Key Encryption & Private Key Decryption

Free online RSA encryption and decryption tool supporting PEM format keys, local processing to ensure data security

Usage Guide

  • RSA encryption requires a public key for encryption and a private key for decryption, supporting standard PEM format
  • Click "Generate Test Key Pair" to generate a 2048-bit RSA key pair for testing
  • For encryption: Enter public key and plaintext, click "Encrypt with Public Key" to generate ciphertext
  • For decryption: Enter private key and ciphertext, click "Decrypt with Private Key" to recover plaintext
  • All RSA encryption and decryption operations are performed locally in your browser; keys and content are never uploaded to any server
  • Supports Unicode characters, outputting Base64 encoded ciphertext after encryption
  • If decryption fails, please verify that the private key format matches and the ciphertext is complete

About RSA Asymmetric Encryption Algorithm & Tool

What is RSA Asymmetric Encryption?

RSA (Rivest-Shamir-Adleman) is the most widely used asymmetric encryption algorithm today, introduced by Ron Rivest, Adi Shamir, and Leonard Adleman in 1977. Unlike traditional symmetric encryption, RSA uses a pair of keys: a public key for encryption and a private key for decryption. This mechanism ensures that encryption and decryption use different keys, significantly enhancing the security of key distribution.

This online RSA encryption tool provides complete RSA encryption and decryption capabilities, supporting PEM format keys. All operations are performed locally in your browser, ensuring that your keys and data remain completely secure and private. The tool is designed for developers, security professionals, and students learning about cryptography fundamentals.

How RSA Encryption Works: Principles and Theory

The RSA algorithm is built upon the mathematical difficulty of factoring large integers. The security of RSA relies on the practical impossibility of factoring the product of two large prime numbers. Here is a breakdown of the core mathematical principles:

  • Key Generation: Two large prime numbers p and q are selected, and their product n = p × q becomes the modulus. The totient function φ(n) = (p-1)(q-1) is calculated, then a public exponent e is chosen such that 1 < e < φ(n) and gcd(e, φ(n)) = 1. The private exponent d is determined as the modular multiplicative inverse of e modulo φ(n). The public key consists of (n, e), and the private key is (n, d).
  • Encryption Process: Using the recipient's public key (n, e), a plaintext message m (converted to an integer) is encrypted by computing the ciphertext c = m^e mod n. This operation is computationally efficient using modular exponentiation.
  • Decryption Process: The recipient uses their private key (n, d) to decrypt the ciphertext c by calculating m = c^d mod n, recovering the original plaintext message. This works because of Euler's theorem, ensuring that (m^e)^d ≡ m mod n.

Given a sufficiently large key size, typically 2048 bits or higher, it is computationally infeasible to derive the private key from the public key within a reasonable timeframe. This fundamental asymmetry is what makes RSA secure for online encryption and digital signatures.

Understanding PEM Format

PEM (Privacy Enhanced Mail) is the standard format for storing and transmitting cryptographic keys and certificates. Its distinctive characteristics include:

  • Begins with a header line "-----BEGIN ...-----" and ends with a footer line "-----END ...-----"
  • Key content is Base64 encoded, typically wrapped at 64 characters per line
  • Common markers include "BEGIN PUBLIC KEY" for public keys, and "BEGIN PRIVATE KEY" or "BEGIN RSA PRIVATE KEY" for private keys
  • PEM files are widely used in web servers, SSH configurations, and SSL/TLS certificate deployments

How to Use This RSA Encryption Tool

Using this RSA asymmetric encryption tool is straightforward. First, you can either paste your existing PEM-formatted key pair into the respective public key and private key fields, or click the "Generate Test Key Pair" button to instantly create a new 2048-bit RSA key pair for testing purposes. Next, enter the plaintext you want to encrypt into the content field, and click "Encrypt with Public Key" to produce Base64-encoded ciphertext. To decrypt, paste the ciphertext into the content field, ensure the corresponding private key is in place, and click "Decrypt with Private Key" to recover the original message. All cryptographic operations run locally in your browser using JavaScript, meaning no data is ever transmitted to a remote server. This tool is ideal for learning RSA encryption online, testing API authentication workflows, and performing free RSA key operations without installing any software.

RSA vs Other Encryption Algorithms

  • Compared to AES Symmetric Encryption: RSA provides a more secure method for key distribution, but its encryption and decryption speed is approximately 1000 times slower than AES. In practice, hybrid cryptosystems are used: RSA encrypts the AES session key, while AES encrypts the bulk data payload.
  • Compared to ECC Elliptic Curve Cryptography: ECC achieves the same security level with much shorter keys; a 256-bit ECC key offers security comparable to a 3072-bit RSA key. This makes ECC more suitable for resource-constrained devices like smartphones and IoT sensors, though RSA remains more widely adopted in legacy systems.
  • Security Recommendation: Currently, 2048-bit or 4096-bit RSA keys are recommended. 1024-bit RSA keys are no longer considered secure against modern attacks and should be avoided.

FAQ - Frequently Asked Questions

Is this online RSA encryption tool safe to use?

Yes, absolutely. This free RSA tool performs all cryptographic operations entirely within your web browser using JavaScript. Your plaintext, ciphertext, public key, and private key are never sent to any server. You can even disconnect from the internet after the page loads and the tool will continue to function perfectly, providing maximum data privacy.

What key sizes does this RSA key generator support?

The built-in key generator creates 2048-bit RSA key pairs, which is the current industry standard for secure applications. 2048-bit RSA keys provide a security level sufficient for most commercial and personal use cases and are expected to remain secure until at least 2030. If you have existing 4096-bit keys generated externally, they are also fully compatible with this tool.

Can I use this tool for encrypting long messages with RSA?

RSA encryption has a limitation on the maximum length of the plaintext it can encrypt, which is determined by the key size minus padding overhead. For a 2048-bit key, the maximum plaintext length is typically around 245 bytes with OAEP padding. For longer messages, the recommended approach is to use a hybrid encryption scheme: generate a random AES key, encrypt the message with AES, and then use RSA to encrypt the AES key. This tool is best suited for encrypting short secrets, session keys, or testing RSA functionality.

How does RSA digital signature work compared to RSA encryption?

RSA digital signatures reverse the role of the keys: the sender uses their private key to sign a hash of the message, creating a signature, and the recipient uses the sender's public key to verify that signature. This process provides authentication and non-repudiation, proving that the message originated from the claimed sender and has not been altered. While this specific tool focuses on encryption and decryption, the underlying RSA algorithm is identical; only the operation order differs.

Why might RSA decryption fail even with the correct private key?

Decryption failures are commonly caused by: key format mismatch (the private key does not match the public key used for encryption), corrupted or truncated ciphertext, incorrect PEM formatting (e.g., extra whitespace or missing header/footer lines), or using a padding scheme that differs from the one used during encryption. Always ensure you are using the exact key pair and that the ciphertext is copied in its entirety.