RSA Key Generator, Encryption & MD5 Hash
Create an RSA public/private key pair, encrypt and decrypt short text with it, and get the MD5, SHA-1, SHA-256 and SHA-512 hash of any text. Everything runs in your browser: nothing you type is sent to a server.
1. RSA key pair
2. Encrypt & decrypt
3. MD5 & SHA hash
How to use this RSA tool
- Create a key pair. Pick a key size and click Generate. You get a public key and a private key in PEM format (choose PKCS#8 or PKCS#1 for the private key). You can also paste your own PEM keys into the two boxes.
- Encrypt. Type a short message and click Encrypt. It is encrypted with the public key, and the result is shown as Base64 text.
- Decrypt. Click Decrypt to turn the Base64 text back into the message with the private key. To decrypt something you received, paste it into the Encrypted text box first.
The idea of RSA: anyone may have your public key and use it to encrypt a message for you, but only your private key can decrypt it. So you can share the public key freely, but never share the private key.
RSA key sizes and message limits
A bigger key is harder to break but slower to create and use. RSA also has a hard limit on message length, because the message must be smaller than the key. This page uses PKCS#1 v1.5 padding, which needs 11 bytes, so the limit is the key size in bytes minus 11.
| Key size | Max message | Encrypted size | Use it? |
|---|---|---|---|
| 1024 bit | 117 bytes | 172 Base64 chars | No, too weak today |
| 2048 bit | 245 bytes | 344 Base64 chars | Yes, the common default |
| 3072 bit | 373 bytes | 512 Base64 chars | Yes, for keys used after 2030 |
| 4096 bit | 501 bytes | 684 Base64 chars | Yes, strongest here but slowest |
English letters take 1 byte each; letters like é take 2 bytes and Chinese, Japanese or Korean characters take 3. Real systems do not encrypt long data with RSA. They encrypt the data with a fast symmetric cipher such as AES, and use RSA only to encrypt the short AES key. This is called hybrid encryption, and it is how HTTPS, PGP and S/MIME work.
MD5 and SHA hashes
A hash turns any text into a short, fixed-length fingerprint. The same text always gives the same hash, and a tiny change gives a completely different one. A hash cannot be turned back into the text, so hashing is not encryption. For example, the text hello gives:
| Algorithm | Hash of "hello" | Still secure? |
|---|---|---|
| MD5 | 5d41402abc4b2a76b9719d911017c592 | No (collisions since 2004) |
| SHA-1 | aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d | No (collisions since 2017) |
| SHA-256 | 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 | Yes |
MD5 is still fine for checking that a download or a file copy is not damaged, and for cache keys or quick IDs. For signatures, certificates or anything an attacker might try to fake, use SHA-256 or SHA-512. To store passwords, do not use any of these directly: use a slow password hash such as bcrypt or Argon2.
The text is hashed as UTF-8, the same as echo -n "hello" | md5sum on Linux or md5(...) in PHP, so the results match those tools. To hash a file, get SHA-384, CRC32 or an HMAC, or check a download against its checksum, use the Hash Generator.
Frequently asked questions
Is it safe to generate RSA keys online?
On this page the keys are created by JavaScript in your own browser, and nothing you type is sent to our server or stored. The key is made with your browser's built-in Web Crypto API, which uses the operating system's secure random generator. Still, for a key that protects a real server or real money, the best practice is to create it with OpenSSL or ssh-keygen on the machine that will use it, so the private key never exists anywhere else.
Which RSA key size should I choose?
2048 bits is the minimum that is considered safe today and the most compatible choice. 3072 bits gives about 128-bit security and is recommended for keys that must stay safe after 2030. 4096 bits is stronger again but slower to create and to use. Do not use 1024-bit keys.
How much text can RSA encrypt?
RSA can only encrypt a message that is shorter than the key. With the PKCS#1 v1.5 padding used here, the limit is the key size in bytes minus 11: 245 bytes for a 2048-bit key, 373 bytes for 3072 bits and 501 bytes for 4096 bits. Letters like é or 中 take 2 or 3 bytes each. To protect longer data, encrypt it with AES and use RSA only to encrypt the AES key.
Why is the encrypted text different every time?
The padding adds random bytes before encryption, so encrypting the same text twice with the same key gives a different result each time. This is on purpose: otherwise someone could guess a short message by encrypting possible answers and comparing the results. Every version still decrypts to the same original text.
Which key formats and padding does this tool use?
The public key is a PEM "BEGIN PUBLIC KEY" block (X.509 SubjectPublicKeyInfo). The private key is PKCS#8 ("BEGIN PRIVATE KEY", used by Java, Node.js and OpenSSL 3) or, if you choose it, PKCS#1 ("BEGIN RSA PRIVATE KEY", the older OpenSSL format). Encryption uses PKCS#1 v1.5 padding and the result is Base64. OpenSSL reads all of these, for example: base64 -d cipher.txt | openssl pkeyutl -decrypt -inkey private.pem. You can also paste your own PEM keys (either private key format) into the key boxes.
Can an MD5 hash be decrypted?
No. A hash is a one-way fingerprint, not encryption, so there is no key that turns it back into the text. Websites that "decrypt" MD5 only look the hash up in huge lists of hashes of common words and passwords. That is why a short or common input can be found, and why MD5 must never be used to store passwords.
What is the difference between MD5, SHA-1 and SHA-256?
All three turn any input into a fixed-length fingerprint: 32 hex characters for MD5, 40 for SHA-1 and 64 for SHA-256. MD5 (since 2004) and SHA-1 (since 2017) are broken: people can create two different inputs with the same hash. They are still fine as checksums against accidental damage, but use SHA-256 or stronger for anything related to security.