Encryption basics (symmetric vs. asymmetric)
Computer Science · Cybersecurity
Question 1 of 10
0Data in readable form before encryption is called:
Stuck? Read the explanation
Unlocks at a streak of 5 correct answers in a row.
Embed this practice on your site or class page
Paste this HTML into your page. Students practise right there; it is free and needs no account.
Encryption basics (symmetric vs. asymmetric) explained
Encryption scrambles data so that only someone with the right key can read it. Symmetric encryption uses one secret key to both encrypt and decrypt. Asymmetric encryption uses a linked pair of keys: a public key that anyone can have, and a private key that its owner keeps secret.
Symmetric encryption is fast, so it suits large amounts of data such as files, video and messages. Its weakness is key sharing: both people need the same secret key, and it must reach the other person without anyone intercepting it.
Asymmetric encryption solves the sharing problem. Anyone can encrypt a message with your public key, but only your private key can decrypt it. It is much slower, so in practice it is often used only to exchange a symmetric key, and that symmetric key then encrypts the data. This hybrid approach is how HTTPS connections typically work.
A common mistake is to think asymmetric encryption is always better because it has two keys. It is slower, and the private key must be protected carefully.
Worked example
A Caesar cipher is a simple symmetric cipher. Number the letters A to Z as 0 to 25. Every letter is shifted forward by the key, here 3, and shifting back by the same key decrypts it. Letters past Z wrap round to A. It is only a teaching example and is easily broken.
- Encrypt CAT: C is 2, and , which is F. A is 0, and , which is D. T is 19, and , which is W. So CAT becomes FDW.
- Decrypt FDW with the same key: subtract 3 from each number to get back CAT.
Key facts
- Symmetric: one shared secret key encrypts and decrypts. It is fast, so it is used for bulk data. The problem is getting the key safely to the other person.
- Asymmetric: a public key encrypts, and only the matching private key decrypts. It is slower, but the public key can be shared openly.
- Hybrid: asymmetric encryption is used to send a symmetric session key, and the session key then encrypts the data. This is the idea behind HTTPS.
- A hash is not encryption. It is a one-way function that gives a fixed-length digest and cannot be reversed. Base64 is only an encoding, not a secret.
- The key must stay secret, not the method (Kerckhoffs's principle).
Worked example 2
Encrypt ZEBRA with a Caesar cipher using the key 5. Then decrypt KVOO using the same key. Letters are numbered A = 0 to Z = 25 and wrap round, so you take the result modulo 26.
Encrypt
- Z is 25, and . Subtract 26 to wrap: , which is E.
- E is 4, and , which is J.
- B is 1, and , which is G.
- R is 17, and , which is W.
- A is 0, and , which is F.
- ZEBRA becomes EJGWF.
Decrypt
- K is 10, and , which is F.
- V is 21, and , which is Q.
- O is 14, and , which is J.
- The last O is also J.
- KVOO becomes FQJJ.
If a subtraction goes below 0, add 26. The Caesar cipher has only 25 useful keys, so trying all of them (brute force) breaks it in moments.
Worked example 3
A group of people want to send private messages to each other. Compare the number of keys needed with symmetric encryption (one shared key for every pair) and asymmetric encryption (one key pair per person) for and .
- The number of pairs is . For 10 people: shared keys.
- For 50 people: shared keys.
- With asymmetric encryption each person has one key pair, which is 2 keys. For 10 people: keys, and each person keeps only their own private key secret.
- For 50 people: keys.
Symmetric keys grow with the square of the group size, and each one must be delivered secretly. Asymmetric keys grow in step with the group, and public keys can be published. That is the key distribution problem in numbers. Even so, real systems use asymmetric encryption only to agree a session key because it is slow.
Worked example 4
A tiny public-key example. Use the toy numbers , public exponent and private exponent . Real keys are hundreds of digits long, so never use numbers like these for security. Encrypt the message and decrypt it again.
- Encrypt with the public key: .
- . Dividing by 33 gives 496 with a remainder of 16, since . So .
- Decrypt with the private key: .
- . Since , the remainder is 4. So , the original message.
Anyone knows and can encrypt. Only the owner knows . Real systems rely on the fact that finding from a very large is too hard.
Common mistakes
- Saying a public key decrypts messages. It encrypts. The private key decrypts.
- Saying asymmetric is simply better. It is slower, so it protects the session key while symmetric encryption protects the data.
- Calling hashing or Base64 encryption. Hashing cannot be reversed and Base64 has no key.
- Forgetting to wrap round at Z in a Caesar cipher, or to add 26 when decrypting below A.
- Sharing the private key or saying it is sent to the sender.
- Saying that encryption on its own proves who sent a message.
Exam tips
- Say which key is used at each stage: who encrypts with what, and who decrypts with what.
- Write each Caesar letter as a number, do the sum, then convert back. It avoids counting along the alphabet.
- For a hybrid question, give three steps: exchange the session key using the public key, encrypt the data using the session key, and say why (speed).
- Use the key words "shared secret key", "public key", "private key" and "session key" exactly.
- Do not claim any method is "unbreakable". Say it is secure while the key stays secret and long enough.
What you will practise
100 multiple-choice questions (Easy, Medium, Hard). Each answer is followed by an explanation.
Example questions
- Encryption:
- Symmetric encryption uses:
- Asymmetric encryption uses:
- The public key is used to:
- The private key is used to:
- AES is an example of which kind of encryption?
- RSA is an example of which kind of encryption?
- A cryptographic hash function is:
…and 92 more.