symmetric vs asymmetric encryption

There are two ways to keep a message secret. Either both sides share one secret key, or each side has a pair of keys where one half can be made public. Almost every secure system you use combines the two.

symmetric: one key

The same key encrypts and decrypts. It is fast, the keys are small, and it can handle any amount of data. AES and ChaCha20 are the ones you will meet.

    alice                                bob
      |                                   ^
   "hello"                             "hello"
      |                                   |
      v                                   |
+-----------+                       +-----------+
|  encrypt  | <-- K           K --> |  decrypt  |
+-----------+                       +-----------+
      |                                   ^
      '-------->  7f3a9c0e41d2...  -------'
                 safe to send in public

The catch is the key itself. Alice and Bob need the same K, and they have to agree on it without anyone else seeing it. Over the internet, with people you have never met, that is the hard part.

asymmetric: a key pair

Each person generates two keys that belong together. The public key can be given to anyone. The private key never leaves its owner. What one key does, only the other can undo.

             bob's key pair
       .------------------------.
       |                        |
  [ public ]               [ private ]
  shared freely            kept secret
       |                        |
       v                        v
anyone can lock          only bob can unlock

Alice encrypts with Bob's public key and only Bob's private key can decrypt it. Nothing secret had to be shared in advance. Run it the other way round and you get digital signatures: Bob signs with his private key, and anyone can check it with his public key.

encrypt   public key   locks     private key  unlocks
sign      private key  signs     public key   verifies

RSA, elliptic curves (X25519, Ed25519) and the new post-quantum algorithms are all asymmetric. They are far slower than symmetric ciphers and only work on small inputs.

side by side

               symmetric          asymmetric
keys           1 shared           1 pair per person
speed          very fast          slow
key sharing    hard               easy
signatures     no                 yes
examples       aes, chacha20      rsa, x25519, ed25519

in practice: both

Real protocols use asymmetric crypto to agree on a fresh symmetric key, then switch to symmetric for everything else. TLS, SSH, Signal and PGP all work this way.

1. key exchange    x25519 / ml-kem       -->  shared secret
2. derive keys     hkdf(shared secret)   -->  session key K
3. bulk data       aes-gcm or chacha20 with K

Asymmetric solves the problem of who can talk to whom. Symmetric does the heavy lifting.