Why encrypt?
Data sent over a network can be intercepted: someone can copy it on the way, for example on public Wi-Fi.
Encryption scrambles the data using a key, so that an interceptor cannot understand it.
The readable data is called plaintext. The scrambled data is called ciphertext.
?Why?Encryption does not stop data being intercepted. It makes intercepted data useless to the thief, which protects passwords, card numbers and private messages.
!Watch outExam answers lose marks for saying encryption stops hacking or interception. Say it makes the data meaningless without the key.
Symmetric encryption
In symmetric encryption, the same key is used to encrypt and to decrypt.
The sender and the receiver must both have this key. So the key itself must be shared.
The problem: if the key is intercepted while it is being sent, anyone can decrypt every message.
e.g.ExampleA Caesar shift is a very simple symmetric cipher. Key = 3: move each letter 3 places on.
HELLO → KHOOR
To decrypt, move each letter 3 places back with the same key.
Try it in the toy: type HELLO as Alice's message with the key set to 3, and check you get KHOOR. Bob decrypts with the same key. Then change Bob's key and see nonsense.
?Why?Real symmetric encryption uses keys of 128 or 256 bits, so there are far too many keys to try. The weak point is sharing the key safely.
There is something to try for this step in the IGCSE library.
Asymmetric encryption
Asymmetric encryption uses two different keys that are made as a matched pair.
The public key is given to everyone. It is used to encrypt data sent to you.
The private key is kept secret by you and never sent. Only it can decrypt data that was encrypted with your public key.
e.g.ExampleAna wants to send Ben a secret message.
1. Ben sends Ana his public key. Anyone can see it; that is fine.
2. Ana encrypts the message with Ben's public key.
3. The ciphertext travels across the internet.
4. Only Ben's private key can decrypt it. Even Ana cannot decrypt it now.
Try it in the toy: the sender is called Alice and the receiver Bob. Press Step to follow the message. Eve cannot open the box with the public key, but Bob opens it with his private key.
?Why?This solves the key-sharing problem. The private key never travels, so it cannot be intercepted.
!Watch outDo not say the private key encrypts the message to the receiver. For sending secret data, the receiver's public key encrypts and the receiver's private key decrypts.
There is something to try for this step in the IGCSE library.