Online Privacy

Symmetric vs. Public-Key Encryption

Compare one-key and two-key encryption, see why real systems combine them, and learn which fits file protection, web traffic and email.

Key takeaways

  • Symmetric encryption shares a single key, so it is very fast but needs a safe way to deliver that key.
  • Public-key encryption lets strangers send you secrets using a key you can publish openly.
  • Most real protocols use public-key methods to set up a temporary symmetric key, then encrypt the data with that key.
  • A public key is only trustworthy if you can confirm whom it belongs to, which is the job of certificates and verification.
  • Key sizes cannot be compared directly between the two families because the underlying math differs.

Symmetric encryption uses one secret key to both lock and unlock data. Public-key encryption uses two linked keys: a public one that anyone may have and a private one that only the owner holds. The first is fast and simple but requires sharing a secret. The second solves the sharing problem but is slower and handles only small pieces of data.

Almost every secure system you use combines them. Once you see how, the design of HTTPS, encrypted messaging and secure email makes sense.

Symmetric encryption: one shared secret

In a symmetric system, the sender and receiver hold identical keys. Think of a lockbox with two copies of the same key. Run the plaintext and key through a cipher and you get ciphertext; run the ciphertext and the same key through the reverse and you get the plaintext back.

Common symmetric ciphers are AES (FIPS 197) and ChaCha20. Block ciphers such as AES process fixed-size chunks and need a mode of operation to handle longer data safely. Stream ciphers such as ChaCha20 generate a keystream that is combined with the data. Modern practice favors authenticated modes, which also reveal tampering.

Strengths:

  • Very fast, often accelerated by the processor.
  • Suitable for large files, disks and video streams.
  • Strong with fairly short keys, such as 128 or 256 bits.

The weakness is distribution. If two people have never met, how does one send the other a key without an eavesdropper copying it? The problem also grows with group size. For every pair among n people to have its own key takes n times (n minus 1) divided by 2 keys. Ten people need 45; a thousand need nearly half a million.

Public-key encryption: a matched pair

Public-key cryptography, introduced openly in the 1970s through work including Diffie and Hellman's key exchange and the RSA system, splits the key in two. The two halves are mathematically related, but working out the private one from the public one is designed to be computationally infeasible.

To send you a secret, someone encrypts with your public key. Only your private key can decrypt it. You can post the public key on a website, since knowing it doesn't let anyone read messages sent to you.

Sending a secret with a public key
Sender Recipient Here is my public key 1 Safe to send openly, but verify it is genuine Send a secret encrypted to that public key 2 Onlookers can copy it but cannot read it Reply protected with the shared secret 3 Only the private key could have recovered it Sender Recipient Here is my public key 1 Safe to send openly, but verify it is genuine Send a secret encrypted to that public key 2 Onlookers can copy it but cannot read it Reply protected with the shared secret 3 Only the private key could have recovered it

The same families of math support digital signatures, where the private key creates a proof that anyone can check with the public key. Signing and encrypting are different operations, and careful systems often use separate keys for each.

The main families are:

  • RSA, whose security relates to the difficulty of factoring very large numbers.
  • Elliptic-curve cryptography, which offers comparable strength with much smaller keys.
  • Finite-field and elliptic-curve Diffie-Hellman, used to agree on a shared secret rather than to encrypt a message directly. See Diffie-Hellman in pictures.
  • Lattice-based schemes such as ML-KEM, designed to resist quantum attacks.

Side by side

Question Symmetric Public-key
Keys involved One shared secret Public and private pair
Speed Very fast Much slower
Data size Any, with a suitable mode Small values, such as a key
Main challenge Delivering the key safely Proving a public key is genuine
Typical uses Disks, files, traffic Key setup, signatures, identity
Examples AES, ChaCha20 RSA, elliptic curves, ML-KEM

Don't compare key lengths across the columns. A 256-bit AES key and a 256-bit elliptic-curve key aren't equivalent in strength, and RSA keys are measured in thousands of bits. Standards bodies publish tables of roughly matching strengths, and the usual advice is to follow current guidance for the algorithm you use.

Why systems use both

The hybrid approach takes the best of each. A public-key step creates or protects a random symmetric key, and that key encrypts the bulk data. The slow math runs once; the fast cipher does the heavy lifting.

The hybrid pattern
1 Check identity Verify the other side's public key through a certificate or comparison. 2 Establish a secret Use key agreement or encapsulation to share fresh key material. 3 Derive session keys A derivation function turns that material into symmetric keys. 4 Encrypt the data A fast authenticated cipher protects everything that follows. 5 Discard the keys Temporary keys are erased when the session ends. Check identity Verify the other side's public key through a certificate or comparison. 1 Establish a secret Use key agreement or encapsulation to share fresh key material. 2 Derive session keys A derivation function turns that material into symmetric keys. 3 Encrypt the data A fast authenticated cipher protects everything that follows. 4 Discard the keys Temporary keys are erased when the session ends. 5

In HTTPS

In TLS 1.3, defined in RFC 8446, the browser and server perform an ephemeral key exchange. The server's certificate and a signature prove it holds the private key matching the name you asked for. Both sides then derive symmetric keys and encrypt the traffic. Because the exchange uses temporary values, someone who records traffic and later steals the server's long-term key still can't decrypt those old sessions. This property is called forward secrecy. The TLS handshake article shows each message.

In file encryption and email

Tools that encrypt a file to several recipients typically encrypt the file once with a random symmetric key, then encrypt a copy of that small key to each recipient's public key. Adding a reader doesn't require re-encrypting a large file. PGP and S/MIME email follow this pattern, described further in is email encrypted.

On your disk

Full-disk encryption is mainly symmetric. A random data key encrypts the drive, and your password or security chip protects that key. Changing your password rewraps the small key instead of rewriting the whole drive.

A worked scenario: sharing a tax folder

Say you want to send a folder of financial records to an accountant. Compare the two approaches.

With symmetric encryption alone, you create an encrypted archive with a long random passphrase and email the archive. The passphrase then has to travel separately, perhaps by phone. If you send it in the same email thread, anyone who gets into that mailbox gets both halves, and the encryption has bought you very little. Next year you either reuse the passphrase, which widens the damage if it leaked, or repeat the phone call.

With public-key encryption, the accountant publishes a public key once, and you confirm its fingerprint over the phone. From then on you encrypt each new folder to that key. No secret ever crosses the network, and a copy of your mailbox contains only ciphertext. The cost is setup: the accountant has to generate keys, protect the private one and replace it if a laptop is lost.

Many firms avoid both by offering a secure upload portal. That relies on TLS, a hybrid system you don't have to manage, though the firm's server can read what arrives. Which is right depends on who needs to be kept out.

The trust problem

Public keys remove the need for a secret channel, but they raise another question: is this key really theirs? If an attacker can swap in their own public key, you'll encrypt perfectly to the wrong person and the attacker can read, re-encrypt and forward your messages. This is a man-in-the-middle attack.

Defenses include:

  • Certificates signed by certificate authorities, used by websites.
  • Trust on first use, as SSH does when it remembers a server's key fingerprint and warns if it changes. See SSH security basics.
  • Out-of-band verification, such as comparing safety numbers or QR codes in person.
  • Key transparency logs, which publish key records so substitutions can be detected.

When a fingerprint changes unexpectedly, find out why before continuing.

A quick hands-on example with SSH keys

You can create a key pair yourself on Windows, macOS or Linux with OpenSSH:

ssh-keygen -t ed25519 -f ~/.ssh/example_key

This writes a private key to example_key and a public key to example_key.pub. Set a passphrase when prompted, so a copied private key isn't immediately usable. The public file is the one you may add to a server's authorized keys. The private file stays on your device.

Note that SSH uses this pair to sign and prove identity, while the session's data is protected with symmetric ciphers negotiated at connection time. It is the hybrid pattern again.

Which should you use?

For most people, the question is already answered by the tool. Still, it helps to know the fit:

  • Protecting your own files or backups: symmetric encryption with a strong passphrase.
  • Receiving sensitive files from others: a tool that uses public keys, so no password has to be sent.
  • Securing a website: TLS, with certificates from a trusted authority, ideally renewed automatically.
  • Logging into servers: key pairs instead of passwords.
  • Chatting privately: an app with end-to-end encryption that handles keys for you.

If you must share a password for a symmetric file, send it through a different channel from the file, such as a phone call.

Managing keys is the hard part

The algorithms rarely fail. Key handling often does. Keep private keys off shared drives and out of source code, protect them with passphrases or hardware, limit how long they remain valid and have a plan to revoke and replace them. For symmetric keys, avoid reusing one across unrelated purposes, and never reuse a nonce (a number meant to be used once) with the same key where the mode forbids it, since that can badly weaken protection. Using a well-maintained library or product that manages these details is far safer than assembling primitives yourself.

Common questions

Is public-key encryption more secure than symmetric?

Neither is better in general. They solve different problems. Security depends on the algorithm, key size, implementation and how keys are protected.

Can I encrypt with my private key?

Some textbooks describe signing that way for RSA, but real signature schemes involve hashing and specific padding, and many have no encryption step at all. Treat signing as its own operation.

Will quantum computers affect both?

A large enough quantum computer would break RSA and elliptic-curve methods. Symmetric ciphers are affected much less, and long keys such as 256 bits retain a wide margin. Post-quantum cryptography covers the replacements.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in Online Privacy →

Latest news on this topic