Encryption transforms readable data (plaintext) into an unreadable format (ciphertext) to protect it from unauthorised access. Understanding the two main approaches is crucial for computer science.
Symmetric Encryption
In symmetric encryption, the same key is used for both encryption and decryption. This is like having a single key that both locks and unlocks a door.
Scenario: Alice wants to send a secret message to Bob
Step 1: Alice and Bob agree on a secret key (e.g., "SECRET123")
• This must happen through a secure channel
Step 2: Alice encrypts her message
• Plaintext: "Meet at noon"
• Key: "SECRET123"
• Ciphertext: "Xk3$p@9nLm2!" (unreadable)
Step 3: Alice sends ciphertext to Bob (can use insecure channel)
Step 4: Bob decrypts using the same key
• Ciphertext: "Xk3$p@9nLm2!"
• Key: "SECRET123"
• Plaintext: "Meet at noon"
The Problem: How do Alice and Bob securely share the key in the first place? If an attacker intercepts the key, they can decrypt all messages.
• Fast - suitable for encrypting large amounts of data
• Simple - one key to manage
• Problem: Key distribution - how to share the key securely?
• If key is compromised, all data encrypted with it is vulnerable
• Examples: AES (Advanced Encryption Standard), DES
Asymmetric Encryption
Asymmetric encryption uses two mathematically related keys - a public key and a private key. What one key encrypts, only the other can decrypt.
Scenario: Alice wants to send a secret message to Bob
Step 1: Bob generates a key pair
• Public key: Can be shared with anyone
• Private key: Bob keeps this secret, never shares it
Step 2: Bob publishes his public key (website, email, etc.)
Step 3: Alice encrypts her message using Bob's PUBLIC key
• Plaintext: "Meet at noon"
• Bob's public key applied
• Ciphertext: "7h$kL@2mNp!" (unreadable)
Step 4: Alice sends ciphertext to Bob (can use insecure channel)
Step 5: Bob decrypts using his PRIVATE key
• Only Bob's private key can decrypt this
• Even Alice cannot decrypt it now!
• Plaintext: "Meet at noon"
Key insight: No secret key ever needs to be transmitted. The public key can be shared openly - knowing it doesn't help an attacker decrypt messages.
• Solves key distribution problem - public key can be shared openly
• Private key never transmitted - more secure
• Slower than symmetric - computationally intensive
• Enables digital signatures (encrypt with private key)
• Examples: RSA, Elliptic Curve Cryptography (ECC)
Comparison
• Symmetric: 1 shared key
• Asymmetric: 2 keys (public + private)
Speed
• Symmetric: Fast
• Asymmetric: Slow
Key Distribution
• Symmetric: Difficult (must share secretly)
• Asymmetric: Easy (public key shared openly)
Best For
• Symmetric: Bulk data encryption
• Asymmetric: Key exchange, digital signatures
Security Risk
• Symmetric: Key interception
• Asymmetric: Private key theft
1. Asymmetric encryption to securely exchange a symmetric key
2. Symmetric encryption for the actual data (faster)
This combines the security of asymmetric with the speed of symmetric.
Choosing Between Symmetric and Asymmetric Encryption
The right method depends on whether the key has to be shared with anybody else.
| Situation | Suitable method | Reason |
|---|---|---|
| The same person or device encrypts and decrypts, such as encrypting a backup or the files stored on a device | Symmetric | The key never has to be sent to anyone, so there is no key distribution problem, and it needs less processing |
| Data is sent to somebody else across a network, such as card details sent to a website | Asymmetric | Only the public key is shared. The private key needed to decrypt the data never leaves its owner |
| A large amount of data is exchanged across a network, such as a secure web session | Both | Asymmetric encryption is used to exchange a symmetric key, which then encrypts the data quickly |