digest.hmac_sha256_base64

STRINGdigest.hmac_sha256_base64STRINGkeySTRINGs

Available inall subroutines.

Returns a SHA-256-based message authentication code based on the supplied key and string s. The returned code is Base64-encoded.

Example

declare local var.hmac_sha256_base64 STRING;
set var.hmac_sha256_base64 = digest.hmac_sha256_base64("key", "input");
# var.hmac_sha256_base64 is now "ngiewTr4gaisInpzbD58SQ6jtK/KDF+D3/Y5O2g6cuM="

Try it out

digest.hmac_sha256_base64 is used in the following code examples. Examples apply VCL to real-world use cases and can be deployed as they are, or adapted for your own service. See the full list of code examples for more inspiration.

Click RUN on a sample below to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

Authenticate JSON Web Tokens at the edge

Decode the popular JWT format to verify user session tokens before forwarding trusted authentication data to your origin.