Module 23 / Security and operations

Module 23 · lesson 3 of 9 · Read 10 min

Secrets and encryption

Encryption in transit and at rest, and where keys live.

Tiffin holds things that would hurt if they leaked. Customer phone numbers and home addresses. Riders' bank account numbers. The API key that lets Tiffin charge cards through its payment provider. The database password. The private key that signs every login token from the last two lessons.

Protecting them comes down to two jobs. First, make the data unreadable to anyone who grabs it in the wrong place: on the wire, on a disk, in a backup. Second, keep the keys that unlock it somewhere much safer than the data itself. Most real leaks aren't broken cryptography. They're a key sitting in the wrong place.

Hashing, encoding and encryption

People mix these three up, so let's pin them down first.

Reversible? Needs a key? Use it for
Encoding (base64, hex) Yes, by anyone No Moving bytes through text. Not security.
Hashing (SHA-256, Argon2id) No No Checking a value without storing it, like passwords
HMAC No Yes Proving a message came from someone who holds the key, like webhook signatures
Encryption (AES-256-GCM) Yes, with the key Yes Hiding data you need to read back later

A base64 string in a config file is not "encrypted". Anyone can decode it in one command.