Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Treatment sign

crypto/signature/hmac::sign


Parameters

↳ var algorithm: string = "sha256"
↳ var encoding: string = "hex"
↳ var key: Secret<string>

Inputs

⇥ data: Stream<byte>

Outputs

↦ error: Block<string>
↦ failed: Block<void>
↦ signature: Block<string>


Signs data with HMAC.

The HMAC of the bytes received through data is computed with key and algorithm (sha256, sha384, sha512, or sha1 for services still using it), and given through signature once data ends, encoded with encoding (hex, in lowercase, base64, or base64url, without padding), such as to sign the body of an outgoing webhook. The key is revealed when the treatment starts.

If the key cannot be revealed, or algorithm or encoding is not supported, failed is emitted and error contains the reason.