Symmetric encryption
The conceptWhy one password both locks and opens a 7-Zip archive
Symmetric encryption scrambles data with a secret key, and only the same key unscrambles it. Lock a 7-Zip archive with a password and 7-Zip turns it into a 256-bit AES key; your friend's copy of the password undoes it.
Unlike a hash from lesson 1, this scrambling is meant to be undone, but only with the key. The scrambled output is called ciphertext and the readable input is called plaintext. Without the key, the ciphertext should look like random bytes.
What it’s forStates the defining rule of symmetric encryption: decrypting with the same key undoes encrypting.
D(K, E(K, P)) = P
- P
- the plaintext, the readable message
- K
- the shared secret key, e.g. 128 or 256 random bits for AES
- E
- the encrypt function, which turns P into ciphertext C
- D
- the decrypt function, which turns C back into P using the same K
What it givesThe original message back, for anyone holding K and for no one else.
- Toy cipher: E(K, P) = (P + K) mod 26, D(K, C) = (C − K) mod 26
- K = 3, P = 7 (letter H): C = (7 + 3) mod 26 = 10 (letter K)
- Decrypt: (10 − 3) mod 26 = 7, so H comes back