AP® Computer Science Principles · Big Idea 5 · Topic 5.6

Symmetric and Public Key Encryption

Symmetric encryption uses one shared key to lock and unlock a message, which means both people need that key safely. Public key encryption uses two linked keys, a public one anyone can use to lock a message and a private one only the receiver has to unlock it.

Symmetric encryption is the simple case: one key encrypts and the same key decrypts, like a single house key that both locks and unlocks the front door. The problem is getting that key to the other person. If you send it over the internet in the open, anyone watching can grab it and read everything afterward. This is called the key distribution problem, and it is the weak point of symmetric encryption: the encryption itself can be strong, but the system is only as safe as the handoff of the key.

Public key encryption solves this with two keys instead of one. Picture an open padlock: the receiver makes copies of their open padlock and sends them out to anyone, keeping the only key to close them. Someone who wants to send a secret message puts it in a box, snaps the receiver's open padlock shut on it, and sends the box. Now only the receiver, with their private key, can open that padlock. The public key only locks; it cannot unlock what it locked, which is why handing it out freely is safe. Mathematically, the two keys are generated as a linked pair, built so that one direction (locking) is easy for everyone but reversing it without the private key is practically impossible.

This matters because it removes the need to ever share a secret key over an insecure channel, which is exactly what makes secure communication between strangers on the open internet possible. Public key encryption sits behind things like sending your card number to a store you have never visited: the store's public key locks the data, and only the store can unlock it. It connects forward to ideas about trust and verifying identity online, since a public key tells you nothing about whether it truly belongs to who it claims to.

Key terms

Symmetric encryption
An encryption method where the same key is used to both encrypt and decrypt a message.
Public key encryption
An encryption method using two linked keys, a public one that encrypts and a private one that decrypts.
Private key
The secret half of a public key pair, known only to its owner, used to decrypt messages.
Key distribution problem
The risk that a shared symmetric key could be intercepted while being sent to the other party.

Watch it explained

  1. How it worksHow does one shared key for locking and unlocking make key delivery the weak point?
  2. How it worksWalk me through the padlock picture of public key encryption, with the open lock sent out first.
  3. Worked exampleTrace a message encrypted with a receiver's public key and decrypted with their private key.
  4. Common mistakeWhy doesn't knowing somebody's public key let you read the messages sent to them?

Check yourself

Your turn1 of 2
A message is encrypted with a receiver's public key, and decrypting it requires their private key. If 70 such messages are sent to the same receiver, how many private key uses does decrypting all of them require?

End of topic.