Hashing, secrets, and the difference that matters
Why does every “forgot password” flow make you set a new one? And why can’t the company just tell you yours?
The answer is this lesson’s star, and it’s the security idea non-technical people are happiest to finally own.
What is hashing?
HashingConcept · lights on your maphashingA one-way transformation. Any input becomes a fixed-size fingerprint with no path back to the original, which suits values that only ever need comparing. It is why a well-run company keeps no password of yours to leak, and how a tampered file betrays itself. is encryption’s one-way sibling. Feed it any input, and it produces a fixed-size fingerprint.
Three properties define it, and the third is the strange one.
“latte4ever!” → a91f42e8c04d…“latte4ever!!” → 07c3d99a1b28…a 4-gigabyte video → 5bb2f0c44e91…Why is there no way back? Because the machine only runs forward. Encryption scrambles in a way its key can unscramble, while hashing has no key and keeps no path home. The only way to find an input matching a fingerprint is to guess inputs and run the machine forward. Hold that thought, since it matters in a moment.
Like last lesson’s encryption, the hashing methods are public and have survived decades of expert attack. One-wayness is the property the math was built for.
You have already met hashes wearing a disguise. Every Git commit from Module 11 is named by one. Those seven-character IDs, 5e8ec29 and friends, are fingerprints of the commit’s entire contents, which is why they can name a change uniquely.
Why they can’t tell you your password
Now comes the star application. A well-run company never stores your password at all. It stores only the fingerprint.
The trick that makes this work is worth slowing down for. Login never has to recover your password. It only has to decide whether the attempt you just typed matches what you set at signup.
The fingerprint machine’s first property makes that decision possible. The same input always produces the same fingerprint, so comparing two fingerprints answers the question exactly as well as comparing two passwords would. Hashing is perfect for values you only ever compare.
And here is the corollary you’re now equipped to feel in your spine. Any service that can email you your old password is storing it recoverably. That convenience is a red flag wearing a costume.
What attackers do with stolen hashes
So if a database of hashed passwords leaks, is everyone finally safe? Not quite. The reason is the thought you were holding. The hash machine is public and runs forward for anyone.
Attackers can’t reverse your fingerprint, but they can guess likely passwords, hash each guess, and look for matches.
stolen print: a91f42e8c04d…“password123” → 7d0afc22… no match“qwerty2024” → e3b91a07… no match“latte4ever!” → a91f42e8c… MATCHTwo defenses blunt this. Password hashes are deliberately built to be slow to compute, so mass guessing gets expensive. And systems add a salt, a recognition term for a random extra ingredient that’s different per user and mixed into each hash. Two users with the same password then get different prints, and precomputed guess tables are useless.
This is why breach disclosures for hashed passwords still say “rotate your password as a precaution.” The hashes did their job, but guessing continues offline, and weak passwords lose that race. It is also the entire argument for long, unique passwords. You cannot be guessed off a list you are not on.
Fingerprints for files
Passwords are only the famous use. Hashes fingerprint anything. Change one byte of a file, and its fingerprint changes completely.
That is how Module 12’s pipeline knows an artifact wasn’t tampered with in the registry. Hash it at build time, hash it again at deploy time, compare the prints. Integrity is verified in milliseconds.
Encoding is not encryption
Next comes a disambiguation that instantly upgrades your credibility.
EncodingConcept · lights on your mapencodingTransforming data for format reasons (base64, URL-encoding). No key, no secrecy, trivially reversible by anyone. Emphatically not encryption, since “it’s base64-encoded” means it is, security-wise, plaintext. reshapes data so it can travel through channels built for a different format. The need is real. Module 2 split the world into text and binary, and sometimes bytes must ride inside a text-only format. Picture an image inside a JSON payload, or an attachment inside an email.
Base64 is the classic tool for the job, and its name says how it works. It respells any bytes using an alphabet of exactly 64 safe characters, the letters, the digits, and two punctuation marks, all of which every text channel accepts. Nothing about the data changes except its spelling.
But look at what it does to the word latte. It becomes bGF0dGU=. It is gibberish to the eye, and reversible by anyone in one line of code because the scheme is public and there is no key. There is no key because there is no secret.
And that is the trap. Looking scrambled is not a security property. The infamous blunder is treating encoded as encrypted, as in “the credentials are base64’d, we’re fine.” They are not fine. Security-wise, that data is plaintext.
You now hold all three transformations, so keep them straight.
The vault, revisited
One question remains. What protects the keys themselves, meaning the API keys, private keys, and database passwords a system holds? Module 8 taught the vault, and this lesson can now explain why the vault is built the way it is.
First, a question the sharp reader is already asking. If hashing is so good for passwords, why not hash these too? Because hashing only works for values you compare. An API key must be presented to Stripe, whole, on every request, and the system needs the value back.
The rule is to hash what you only ever compare, and to encrypt and vault what you must use again.
SecretsConcept · lights on your mapsecretThe credentials a system itself holds, from API keys to the database password. Anything that would hand an outsider real access belongs in the vault, never in code or config. therefore live in the secrets managerConcept · lights on your mapsecrets managerThe vault. A dedicated service that stores credentials sealed, gates each one to the identity entitled to it, records every access, and swaps values in one place when rotation day comes. because the vault provides what code-and-config never can. Each capability is a concept you now own.
- Encryption at rest, so the stored secrets are sealed (last lesson)
- Least-privilege access, so each identity reads only its own secrets (lesson one)
- An audit log of every read, recording who touched what and when (Module 7’s discipline)
- Centralized rotation, replacing a credential in one place (next section)
The vault, in other words, is this module’s whole toolkit, applied to the keys themselves.
What is key rotation?
Credentials age like milk, not wine. Key rotationConcept · lights on your mapkey rotationSwapping credentials out for new ones at set intervals, so a stolen one expires even when the theft went unnoticed. Rotation day also flushes out any copies hiding in code, since those are the ones that break. replaces them with fresh ones, on a schedule.
The first reason is the one you’d guess. A stolen key often gets stolen silently, and you may never learn it happened. Rotation caps the shelf life of a theft you don’t know about.
The mechanics are deliberately boring. Issue the new key, let old and new overlap briefly while every consumer switches over, verify, then disable the old one. The overlap window is what makes rotation a non-event instead of an outage.
The second reason to rotate is sneakier. Rotation day is a smoke test for hygiene, where every forgotten hard-coded copy of the old key, Module 8’s sin, announces itself by breaking. That breakage is the point.
Teams that rotate calmly are teams whose secrets all live where they should. That is why “we can’t rotate that key” is one of engineering’s most revealing sentences. It admits that nobody knows every place the key lives, and it means a stolen copy could never be replaced.
The mental model to remember
Hashing is the one-way fingerprint. Same input, same print, and the machine only runs forward. Passwords are stored as hashes, and “we can’t tell you your password” is the system working.
The one attack left is guessing forward, which is why password hashes are slow and salted, and why long, unique passwords win. You can’t be guessed off a list you’re not on.
Three transformations do three jobs. Encoding reshapes with no secrecy, encryption protects with keys, and hashing fingerprints with no way back for anyone. Looking scrambled is not a security property.
Hash what you only ever compare, and encrypt and vault what you must use again. The vault applies this module’s whole toolkit to the keys themselves, keeping them sealed, gated, audited, and rotatable.
Key rotation caps the shelf life of silent theft and flushes out every hard-coded copy. Calm rotation is a health indicator, and “we can’t rotate that key” is a confession.
You should now be able to read a breach disclosure and know instantly which word is reassuring and which is a confession, “hashed” or “encoded”, and why even the reassuring one ends with “rotate your password as a precaution.”
Two breach disclosures land the same week. Company A: “attackers accessed our user database; passwords were hashed.” Company B: “attackers accessed our user database; passwords were base64-encoded.” Rank the disasters.
▼ answer the check to continue ▼