HMAC

HMAC (Hash-based Message Authentication Code) is a keyed hash that uses a secret key and a cryptographic hash function, such as SHA-256, to authenticate a message. It allows the receiver to verify that the message was produced by someone holding the secret key and has not been modified.

Minimal example

go
mac := hmac.New(sha256.New, secret)
mac.Write([]byte(message))
tag := mac.Sum(nil)

Learn this concept

Lesson 2.21 · HMAC signing for cursors

Used in exercises

Exercise 2.22 · GET /v1/restaurants: signed cursors Exercise 8.4 · Payment processing service Exercise 8.13 · Timestamped webhook signature package