keyed hash
A hash computed with a secret key mixed in, so only someone who holds the key can produce or check the correct value.
In more detail
A plain, unkeyed hash spots accidental change, but anyone who alters a message can simply recompute it, and anyone can hash every possible value of a short input, such as a card number, to reverse it. Mixing in a key, as HMAC does, blocks both: outsiders cannot produce a matching value or test guesses. The key must be stored away from the hashed data, or the protection is lost.
Example
hmac.new(KEY, msg, "sha256").hexdigest()Related terms
- HMAC — A way of combining a secret key with a hash function to produce a tag that shows a message came from someone holding the key and was not changed.
- hash — A short fixed-length fingerprint calculated from data, which changes completely if even one byte of the data changes.
- MAC — A short tag computed from a message and a secret key, which lets the receiver check the message is unchanged and came from a key holder.
- SHA-256 — A widely used hash function that turns any data into a 256-bit fingerprint, shown as 64 hexadecimal characters.
Taught in
- CIA Triad, Non-Repudiation & Parkerian Hexad — Cybersecurity Fundamentals, GRC & Cryptography
- Regulatory Compliance: SOC 2, HIPAA, GDPR & PCI-DSS — Cybersecurity Fundamentals, GRC & Cryptography