Cryptography at work
Cryptographic hash
A one-way function that turns any data into a short fixed-size fingerprint, so the same bytes always give the same digest and no one can find two inputs that share one.
A cryptographic hash turns any data into a fixed-size digest: SHA-256 always gives 64 hex characters. The same bytes always give the same digest, one changed bit gives an unrelated one, and it cannot be run backwards. No one can find two inputs that share a SHA-256 digest; for MD5 and SHA-1 they can, so avoid those. A digest alone proves a match, not who published it: see [[integrity-vs-authenticity]].
Read next
- Message authentication code A keyed hash: a tag computed from a message and a secret key, so only a holder of the key can produce or check it.
- Integrity versus authenticity Integrity asks whether the bytes match a digest you trust; authenticity asks whether they came from who you think — a bare hash gives the first, a keyed hash or signature the second.
- Hashing, salting and key exchange The building blocks under TLS and passwords: one-way hashes, salts, key pairs and agreeing a key in public.
- Salted password storage Storing a password as a hash of the password plus a per-account random salt, so a precomputed table is useless and two accounts with the same password store different hashes.
- Encoding vs encryption Obfuscation hides a payload with reversible transforms — base64, hex, a short XOR — that use no key, so unlike encryption it peels straight back to the original: encoding, not encryption.