All articles
165 articles · updated weekly See our Tools
All articles
Comparisons

Symmetric vs asymmetric encryption: the difference that confuses everyone

Symmetric uses one key, asymmetric uses a public/private pair, and hashing isn't encryption. Learn when to use each and why TLS relies on both.

Symmetric vs asymmetric encryption: the difference that confuses everyone
COVER · Comparisons

Every other week someone shows up in the engineering channel saying they're going to "encrypt the password in the database with a secret key." And almost always, what they actually want isn't encryption at all. The classic confusion is treating everything as just "a key": TLS, user passwords, session tokens, all tossed in the same bucket. But there are two models of cryptography that work in opposite ways, plus a third concept, hashing, which is exactly where most people slip.

This post separates the three: symmetric encryption, asymmetric encryption and hashing. The difference between symmetric and asymmetric encryption, example algorithms for each, why TLS combines both (and how that combination has already gone post-quantum in your browser), and why a hash isn't encryption. The commands were run in an Alpine container with OpenSSL 3.3 and 3.5.

The difference in one sentence

Symmetric encryption uses a single key to encrypt and decrypt: the same key that locks, unlocks. Asymmetric encryption uses a mathematically linked key pair, the public key and the private key: the public key encrypts or verifies, the private key decrypts or signs.

It sounds like a detail, but it changes everything about who can read what and, above all, how you hand the key to the other side.

Symmetric encryption: fast, and the problem is the key

In symmetric encryption both ends hold the same key, a sequence of bytes (256 bits in AES-256). The sender encrypts, the receiver decrypts with the same key. Examples of symmetric algorithms:

  • AES: the current standard, preferably in AES-GCM mode, which encrypts and also authenticates (it detects whether the ciphertext was tampered with).
  • ChaCha20-Poly1305: the modern alternative, also authenticated, fast on CPUs without AES acceleration.
  • DES and 3DES: they show up in every list of examples and every exam, but they're obsolete. Don't use them in anything new.

The big advantage is speed. AES is hardware-accelerated on most CPUs (AES-NI instructions), so encrypting a 5 GB backup, a disk volume or a video stream is a job for symmetric encryption.

The command-line example almost every tutorial gets wrong

The reflex is to ask openssl enc for AES-GCM. It doesn't work:

$ openssl enc -aes-256-gcm -pbkdf2 -salt -in data.txt -out data.enc -pass pass:mypassword
enc: AEAD ciphers not supported

The openssl enc documentation says it doesn't support authenticated encryption modes such as GCM and CCM. What runs is CBC:

openssl enc -aes-256-cbc -pbkdf2 -iter 600000 -salt -in data.txt -out data.cbc
openssl enc -d -aes-256-cbc -pbkdf2 -iter 600000 -in data.cbc -out data.txt

-pbkdf2 with a high -iter derives the key from the password slowly, which makes brute force more expensive. But CBC does not authenticate. To prove it, I flipped one byte of the encrypted file and decrypted again: openssl exited with code 0 and handed back text with the first block turned to garbage and one character changed in the second, with no warning at all. Whoever tampers with the file in transit can alter the content blindly.

To encrypt files for real, use a tool that authenticates, such as age:

age-keygen -o key.txt              # generates the key pair
age -r age1zgyg4lak... -o data.age data.txt
age -d -i key.txt data.age

With the same byte flipped, age refuses: failed to decrypt and authenticate payload chunk. (It also has age -p, which encrypts with a passphrase.) And look at the header of the generated file, -> X25519: age uses a public key to protect a random file key and encrypts the content with ChaCha20-Poly1305. That's hybrid encryption, the subject of the section after next.

The problem with symmetric encryption, in the end, isn't encrypting: it's distributing the key. How do you hand that key to whoever needs to decrypt without someone intercepting it on the way? If you email the key alongside the file, you protected nothing. That's the problem asymmetric encryption solves.

Asymmetric encryption: public key and private key

In asymmetric encryption you generate a pair. The public key can go out to the whole world: GitHub, email, your website. The private key stays guarded and is never shared. The pair serves two different uses:

  • Secrecy: someone encrypts with your public key and only your private key decrypts. Anyone can send you something; only you can read it.
  • Digital signature: you sign with your private key and anyone verifies with your public key. It proves the message came from you and wasn't altered.

Examples of asymmetric algorithms, by what each one does:

  • RSA: encrypts and signs. It's the only one of the classics where you can say "what one key does, the other undoes."
  • ECDSA and Ed25519: signatures only, using elliptic curves (ECC). Signing with ECDSA is not "encrypting with the private key"; it's a signature algorithm in its own right.
  • ECDH and X25519: key exchange only. Both sides agree on a shared secret without ever sending it over the network. ECC doesn't encrypt data directly; when it needs to, it uses ECDH to agree on a symmetric key (that's what the ECIES scheme and age do).
  • ML-KEM: the post-quantum key encapsulation mechanism standardized by NIST in FIPS 203 (2024). It also establishes a key; it doesn't encrypt data.

The price is speed: asymmetric operations are orders of magnitude more expensive than AES. Nobody encrypts 5 GB with RSA. Asymmetric encryption exists to solve what symmetric can't: agreeing on the key and proving identity.

Hybrid encryption: how TLS uses both

In practice, almost every serious protocol is hybrid encryption: asymmetric crypto agrees on the key and authenticates the parties, symmetric crypto encrypts the bulk. TLS, SSH, PGP and age itself follow this design.

A detail a lot of writing still gets wrong: in TLS 1.3 the browser does not encrypt the session key with the server's RSA key. That mode (static RSA key transport) was removed in TLS 1.3 (RFC 8446). What happens instead is an ephemeral key agreement (ECDHE): client and server agree on a fresh secret for every connection, and the server's certificate is only used to sign the handshake and prove it is who it claims to be. I made a test connection with OpenSSL 3.5:

$ echo | openssl s_client -connect www.cloudflare.com:443 2>/dev/null | grep -E "group|signature type|Cipher is"
Peer signature type: ecdsa_secp256r1_sha256
Negotiated TLS1.3 group: X25519MLKEM768
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384

Those three lines tell the whole story:

  1. X25519MLKEM768: the key agreement. It's hybrid in a second sense too: it combines classical X25519 with post-quantum ML-KEM-768, and the key only falls if both fall. Chrome began offering this group by default in Chrome 131 (November 2024), the IETF standardized it in RFC 10024 (2026), and Cloudflare reported in September 2026 that about 70% of browser traffic reaching its network already uses hybrid ML-KEM.
  2. ecdsa_secp256r1_sha256: the certificate signature. Authentication is still classical (ECDSA or RSA); post-quantum certificates are only getting started.
  3. TLS_AES_256_GCM_SHA384: the session. All traffic from here on is AES-GCM, symmetric.

In other words: the asymmetric part solves the hard problem (agreeing on the key and proving identity) and the symmetric part does the heavy lifting. For the practical side of certificates (issuance, validity, what the padlock guarantees), see is a free SSL certificate secure?. Another everyday example is JWT: HS256 signs with HMAC and a shared secret (symmetric), while RS256 and ES256 sign with a private key and verify with the public one (asymmetric); details in how JWT works.

Symmetric Asymmetric
Keys One, shared Pair: public key and private key
Speed Very fast Orders of magnitude slower
Good for Encrypting bulk data Key exchange and digital signatures
Problem Distributing the key Computational cost
Examples AES, ChaCha20, (DES and 3DES, obsolete) RSA, ECDSA, Ed25519, ECDH, X25519, ML-KEM

Hashing is not encryption

Now the point that confuses people most, and the root of that "encrypt the password" request. Encryption is reversible by definition: there's a key that undoes it. A hash is a one-way function: you feed in data and get a fixed-size value back, and there's no operation that recovers the input from the hash. A plain hash uses no key.

The exception worth knowing is HMAC, a hash computed with a secret key. It hides nothing; it only proves that whoever produced the value knew the key and that the content didn't change. It's how providers sign webhooks, and it's what sits behind JWT HS256.

Being one-way is exactly why hashing is the right way to store passwords: you never want to be able to "decrypt" a user's password, because if you can, whoever steals your key can too. For passwords, use deliberately slow functions such as Argon2id or bcrypt, never a raw SHA-256. The fundamentals are in hashing for those who never read the RFC and the algorithm choice in password hashing: bcrypt, scrypt and Argon2.

When to use which

  • Encrypt bulk data (files, backups, large payloads): authenticated symmetric encryption, AES-GCM or ChaCha20-Poly1305.
  • Agree on a key over an open channel or prove identity: asymmetric, preferably inside a ready-made protocol (TLS, SSH, age).
  • Store passwords: a slow hash (Argon2id or bcrypt). Check integrity: SHA-256. Authenticate a message with a shared secret: HMAC.

And the opinion you've been waiting for: don't roll your own crypto. It's one of those areas where code that passes the tests can be completely broken against an attacker; the CBC example above "successfully" decrypts a tampered file. Use vetted libraries (libsodium, your language's crypto module, the system's TLS) and leave modes of operation, nonces and padding to people who already solved them. For the backdrop (confidentiality, integrity, authenticity), read the information security fundamentals.

Frequently asked questions

Symmetric or asymmetric encryption: which is better?

Neither is better; they solve different problems. Symmetric is fast and ideal for encrypting large volumes, but it requires distributing the key securely. Asymmetric is slow but lets you agree on keys over an open channel and sign data. That's why real systems use hybrid encryption, with both.

Why does TLS use both types of encryption?

Because each covers the other's weakness. In TLS 1.3, the ephemeral key agreement (today, in up-to-date browsers, the hybrid X25519MLKEM768) and the certificate signature are asymmetric; once the key is agreed, session traffic is encrypted with AES-GCM or ChaCha20-Poly1305, both symmetric. Using asymmetric crypto for everything would be far too slow; using symmetric alone would leave you no safe way to agree on the key.

Is hashing a type of encryption?

No. Encryption is reversible with a key; a hash is a one-way function with no way back. HMAC uses a key, but to authenticate, not to hide. It's precisely because it's irreversible that hashing (with Argon2id or bcrypt) is the right way to store passwords.

Which algorithms should I use today?

Symmetric: AES-GCM or ChaCha20-Poly1305. Signatures: Ed25519 or ECDSA P-256; RSA at 2048 bits or more only where compatibility demands it. Key exchange: X25519, and the hybrid X25519MLKEM768 where your stack supports it (OpenSSL 3.5 negotiates it by default). Passwords: Argon2id or bcrypt. And always through a vetted library, never implemented by hand.

One key, a pair, no key

Symmetric is a single key, fast, and the hard part is distributing it. Asymmetric is the public/private key pair, slow, and it solves key exchange and digital signatures. The real world uses both together: TLS agrees on the key with an ephemeral exchange (already post-quantum in most browsers), authenticates with the certificate and encrypts the session with AES. Hashing isn't encryption: it's one-way and it's the right way to store passwords. And, again: don't write your own crypto, and distrust any tutorial that tells you to run openssl enc with GCM.

The editorial content ends here. To see in practice that a hash has no key and no way back, the Quick Tools hash generator shows the entire output changing when you change one character of the input. The Caesar cipher is the oldest example of a symmetric cipher (the shift is the key, and breaking it is trivial), and the bcrypt generator shows what a password hash with salt and cost looks like.

RD
Author
Rafael Duarte
Backend developer with a background in fintech and B2B SaaS — worked on teams that scaled APIs from zero to millions of requests. Carries enough production scars to hold strong opinions on tools, patterns and architecture decisions. Not an academic: he read the UUID RFC when he had to choose between v4 and v7 for a write-heavy table.
View profile