C3 Hash and HMAC

Needs: Supporter

SHA-1 and SHA-2, HMAC, and the difference between a hash, a MAC and a signature.

This is a supporter feature. Create a free account, then try every supporter feature free for 7 days.

Sign in Create a free account See plans

What this module covers

Track C · Cryptography

You will be able to

  • Name SHA-1 and SHA-256 uses in payments
  • Compute an HMAC
  • Tell a hash from a MAC and a signature

The lesson

  1. Why it matters
  2. The concept
  3. Step by step
  4. In the real world
  5. Common mistakes
  6. What to test

In the module

  • The lesson, with diagrams, common mistakes and what to test
  • A worked example you can change: Hash and HMAC
  • Practice: 3 kinds of generated exercise, each with a step-by-step solution
  • A quiz of 8 questions

Key terms

Collision
Two different inputs with the same digest. A good hash makes finding one impractical.
Digest (Hash value)
The output of a hash function.
Hash function
A function that turns any data into a fixed-size digest that changes completely when one bit of the input changes.
HMAC
A MAC built from a hash and a secret key. Used in APIs and some tokenisation and key derivation schemes.
Salt
Random data added to a value before hashing, so that equal values do not give equal digests. Hashing a PAN without a secret or salt does not protect it.
SHA-1
A 160-bit hash, broken for collisions. Still met in older EMV certificates; not for new designs.
SHA-2
The family of SHA-224, SHA-256, SHA-384 and SHA-512, the current standard hashes.

Tools for this module: Hash & HMAC

Read the opening of the lesson →

The lesson, worked example, practice and quiz open with a supporter pass, which you can try free for 7 days.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.