Symmetric Encryption
Every night Tiffin's pipeline dumps the orders database to a file and copies it to cloud storage. That file holds names, addresses and phone numbers. If the storage is ever exposed, the backup should be useless to whoever finds it. That is a job for symmetric encryption, and the whole job depends on one question.
The rule
One key locks and unlocks, so guard the key harder than the data.
In symmetric encryption the same secret key turns readable plaintext into scrambled ciphertext and back again. The standard choice today is AES (Advanced Encryption Standard), usually with a 256-bit key.
# encrypt the backup with a key from a separate, protected store
openssl enc -aes-256-cbc -pbkdf2 -in orders.sql -out orders.sql.enc -pass file:/run/keys/backup.keySymmetric encryption is fast, which is why it protects bulk data: disks, database files, backups, and the traffic inside a TLS connection once it is set up.
Its weakness is the key. Everyone who needs to decrypt needs the same key, so the key must be created, stored, shared and eventually replaced safely. Encryption does not remove the secret; it shrinks a big secret (the data) into a small one (the key).
Two rules keep you out of trouble:
- Use a standard, authenticated mode such as AES-GCM through a well-known library. "Authenticated" means tampering with the ciphertext is detected on decrypt, which protects integrity as well as confidentiality. The
opensslline above is fine for a quick demo; in application code prefer an authenticated mode. - Never invent your own cipher or mix your own scheme. Home-made cryptography fails in ways you cannot see.
The shortcut
Whenever you see "encrypted", ask: "Where does the key live, and who can reach it?" If the answer is "the same place as the data", the encryption is decoration.
The data
orders.sqlcontains customer details. Confidentiality matters.
Drills
Answer fast — trust the rule.
What defines symmetric encryption?
What is the main practical difficulty of symmetric encryption?
Tiffin stores backup.key in the same bucket as the encrypted backups. What does the encryption protect against?
Why prefer AES-GCM over a plain encryption mode in application code?
Remember
- One key locks and unlocks, so guard the key harder than the data.
- Ask "where does the key live, and who can reach it?"
- Use standard authenticated modes like AES-GCM; never invent your own.
