Hash

Auth

Content digests and HMAC for webhooks, ETags, and signed payloads.

Prefer Password for storing user secrets and Jwt for tokens. Use this module for checksums and keyed message authentication.

Values

sha256

sha256 : Bytes -> Bytes

SHA-256 digest of data.

Examples

Hash.sha256 bodyBytes

hmacSha256

hmacSha256 : Bytes -> Bytes -> Bytes

HMAC-SHA256 of message under key.

Examples

Hash.hmacSha256 secretKey payload

equal

equal : Bytes -> Bytes -> Bool

Constant-time equality for equal-length digests. Different lengths are always False (not constant-time across length).

Examples

Hash.equal expectedDigest actualDigest

toHex

toHex : Bytes -> String

Lowercase hex encoding of bytes.

Examples

Hash.toHex (Hash.sha256 bodyBytes)

fromHex

fromHex : String -> Maybe Bytes

Decode a hex string (case-insensitive). Returns Nothing on invalid input.

Examples

Hash.fromHex "deadbeef"