AES or RSA? Symmetric, Asymmetric and What Morse Code Is Not
Picking the wrong encryption scheme rarely throws an error - it just leaves your data quietly exposed. AES and RSA differ by orders of magnitude in speed, and real systems use them together rather than choosing one.
- AES is symmetric, so the same key encrypts and decrypts, and it is orders of magnitude faster than RSA - use it for data of any length
- RSA is asymmetric: the public key encrypts and only the private key decrypts, and the key size caps how much you can encrypt in one go
- Real systems encrypt an AES key with RSA and the payload with AES; this hybrid scheme is exactly what the TLS handshake does
- A key and an IV must never be reused together, because identical plaintext then produces identical ciphertext and leaks the structure of your data
- DES has only 56 bits of effective key, so it should not protect new data - its remaining job is reading legacy archives
- Morse code is a public encoding table that anyone can reverse, so it changes representation without providing any confidentiality
#Symmetric and asymmetric encryption differ in one sentence
Symmetric encryption uses one shared key for both directions; asymmetric encryption uses a key pair, with the public key encrypting and the private key decrypting. That single difference dictates the speed, the usable length and the right use case.
| Property | Symmetric (AES) | Asymmetric (RSA) |
|---|---|---|
| Keys | One, shared by both sides | A pair: public shared, private kept |
| Speed | Fast, built for bulk data | Slow, typically thousands of times slower |
| Input length | Any length | Capped by key size |
| Main job | Encrypting the data itself | Exchanging keys, digital signatures |
| Examples | AES-128/256, DES | RSA-2048/4096 |
Hand a long paragraph to AES / DES Encrypt and it finishes instantly; hand the same paragraph to RSA and it slows down visibly before hitting a hard length limit.
#Which AES mode should you pick
Use AES-GCM for anything new, because it authenticates as it encrypts. Reach for CBC only when an existing system forces you to.
AES / DES Encrypt offers these combinations:
| Mode | Built-in authentication | When to use it |
|---|---|---|
| AES-128-CBC | No | Legacy interfaces, with a separate integrity check |
| AES-256-CBC | No | Same, with a longer key |
| AES-GCM | Yes | Recommended - any tampering makes decryption fail |
| DES-CBC | No | Reading legacy data only |
CBC has a known weakness: an attacker who flips one byte of ciphertext can cause a predictable change in the decrypted plaintext. GCM computes an authentication tag over the ciphertext, so modified data simply fails to decrypt.
DES has only 56 bits of effective key - about 7.2x10^16 combinations - which dedicated hardware can exhaust in a matter of days. Being decryptable is not the same as being secure. Seeing DES should mean one thing: you are reading old data.
#Why a key and an IV must never be reused
The same key plus the same IV plus the same plaintext always produces the same ciphertext, so an attacker can spot identical records without decrypting anything.
IV reuse does the most damage on fixed-format data:
- A nightly report with an unchanging structure emits the same ciphertext block for the same field
- The distribution of values, and how many records are duplicates, becomes visible
- If the plaintext is guessable - a handful of status values, say - an attacker can build a lookup table
So use a fresh IV for every encryption and store it beside the ciphertext. An IV is not a secret; it only has to be unique, and unpredictable as well under CBC:
storage: [ IV (16 bytes) ][ ciphertext ]
encrypt: make a random IV -> encrypt with IV + key -> store both
decrypt: read the first 16 bytes as the IV -> decrypt with IV + keyA CBC IV must be unpredictable, and a GCM IV must be unique every single time. Reusing one IV under GCM leaks the authentication key outright, which is worse than the CBC case. That is why AES / DES Encrypt generates a random IV whenever you leave the field blank - hard-coding something like 1234567890123456 is a common mistake.
#RSA can only encrypt data shorter than its key
RSA's single-pass limit is set by the key size: about 190 bytes for a 2048-bit key and about 446 bytes for 4096 bits. One byte over and it errors out.
| Key size | Single-pass limit (OAEP + SHA-256) | Notes |
|---|---|---|
| 2048-bit | 190 bytes | The minimum acceptable strength today |
| 3072-bit | 318 bytes | More margin |
| 4096-bit | 446 bytes | Slower to generate and use |
The limit comes from the formula key bytes - 2 x hash length - 2. A 2048-bit key is 256 bytes, SHA-256 is 32 bytes, and 256 - 64 - 2 = 190.
So the real-world pattern is not "encrypt data with RSA" but "encrypt an AES key with RSA, then encrypt the data with AES". An AES-256 key is only 32 bytes, which RSA handles easily.
#Do not reverse the public and private key roles
Two directions cover everything you need: public key encrypts and private key decrypts; private key signs and public key verifies.
Encrypting with the private key and decrypting with the public key is mathematically possible, but since the public key is public, anyone can undo it. It therefore proves nothing about confidentiality and exists purely inside digital signatures.
| What you want | Which key |
|---|---|
| Let someone send you encrypted data | They encrypt with your public key |
| Read what you received | You decrypt with your private key |
| Prove a message came from you | You sign with your private key |
| Verify a signature | Anyone verifies with your public key |
RSA Encrypt generates 2048, 3072 or 4096-bit key pairs and can import existing PEM keys. Long input is chunked automatically.
For keys you intend to keep, generate them locally:
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -pubout -out public.pemOnline tools are for verifying a workflow, not for real secrets. A production private key should never pass through any website, this one included.
#Morse code is not encryption
Morse code is a completely public encoding table that anyone can reverse, so it offers no confidentiality at all.
There is only one test that matters: if you need a key to reverse it, it is encryption; if you do not, it is encoding.
| Method | Needs a key | Nature |
|---|---|---|
| AES / RSA | Yes | Encryption |
| Morse code | No | Encoding |
| Base64 | No | Encoding |
| Hashing | No, and irreversible | One-way digest |
Use Morse Code to convert between text and dots and dashes, with / separating words:
SOS -> ... --- ...
HELLO -> .... . .-.. .-.. ---#Which tool for which job
| What you need | Tool | Notes |
|---|---|---|
| Encrypt text or a payload | AES / DES Encrypt | AES-128/256-CBC, AES-GCM, DES-CBC |
| Generate a key pair, encrypt a small value | RSA Encrypt | 2048/3072/4096-bit, PEM import and export |
| Check whether a file changed | SHA Hash | One-way and irreversible |
| Produce a short digest | MD5 Hash | No longer suitable for security |
| Move binary data through text | Base64 Encode/Decode | Encoding only - anyone can reverse it |
| Convert Morse code | Morse Code | Encoding practice and curiosity |
#Frequently asked questions
#If AES is enough, why do we still need RSA?
Because AES requires both sides to already share a key, and getting that key to the other party safely is the hard part. RSA solves exactly that step: the public key travels openly, the private key never leaves your machine, and only you can decrypt the AES key someone encrypted for you. They work as a pair, not as alternatives.
#Which is more secure, AES or RSA?
Used correctly, both are strong enough; the difference is fit. AES-256 has a 2^256 key space with no feasible brute-force route, and RSA-2048 rests on the difficulty of factoring large integers. Almost every real breach comes from misuse - a reused IV, a key hard-coded in source, or a mode without integrity checking.
#What is the difference between a key and an IV?
The key must stay secret. The IV does not, but it must be unique every time, and unpredictable as well under CBC. Its purpose is to make the same plaintext encrypt differently under the same key. Store the IV in the clear in front of the ciphertext and read it back before decrypting.
#Why does encrypting a long string with RSA fail?
RSA-OAEP can encrypt key bytes minus 2 x hash length minus 2 bytes in one pass. With a 2048-bit key and SHA-256 that is 190 bytes, and a single extra byte raises an error. RSA Encrypt chunks long input automatically, but the better design is to encrypt an AES key with RSA and let AES handle the body.
#Can Morse code be used to encrypt a message?
No. The Morse table is public and any online lookup reverses it instantly, which puts it in the same category as Base64 and URL encoding: it changes the representation and nothing else. If reversing it needs a key it is encryption; if it does not, it is encoding - and that test works for every scheme.
Tools used in this guide
AES/DES symmetric encryption with AES-128/256 CBC modes
Open tool →RSA EncryptRSA online encryption with 2048/3072/4096-bit key generation
Open tool →Morse CodeMorse code converter for letters, numbers and punctuation
Open tool →MD5 HashGenerate a 32-character MD5 digest for text or a whole file
Open tool →SHA HashSHA-1 / SHA-256 / SHA-512 hash generator for text or files
Open tool →Base64 Encode/DecodeEncode and decode Base64 text with UTF-8 support; use the image tool for files
Open tool →