Available in all subroutines.
The alphabet used is:
The output string is padded to a multiple of four characters in length
for details on the structure of Base64 encoding. In particular,
note that it is possible for two input strings to encode to the same
declare local var.base64_encoded STRING;set var.base64_encoded = digest.base64("Καλώς ορίσατε");# var.base64_encoded is now "zprOsc67z47PgiDOv8+Bzq/Pg86xz4TOtQ=="
Try it out
digest.base64 is used in the following solution recipes, which show real world use cases. Click RUN to provision a Fastly service, execute the code on Fastly, and see how the function behaves.
Send HTTP Basic Auth in request to origin
Convert a password sent by the client in the querystring into a Authorization header to your origin server.
Cache GraphQL query response
GraphQL query requests are POSTs, but normally responses to POST can't be cached. Normalize the query and convert it to a querystring on a GET request to allow Fastly to cache these responses.
User contributed notes
We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.