---
title: digest.base64
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/functions/cryptographic/digest-base64
---

```
STRING digest.base64(STRING input)
```

**Available in:** all subroutines

Returns the Base64 encoding of the input string,
as specified by [RFC 4648](https://tools.ietf.org/html/rfc4648)
and is suitable for decoding by
`digest.base64_decode()`.

> **IMPORTANT:** 
> Although Base64 can encode binary data, the input to this function
> is treated as a string. The STRING type in VCL cannot contain _NUL_ characters.
> As such, it is not possible to encode _NUL_ characters using this function.

The alphabet used is:

```
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789+/
```

The output string is padded to a multiple of four characters in length
using the `=` character.

See `digest.base64_decode()`
for details on the structure of Base64 encoding. In particular,
note that it is possible for two input strings to encode to the same
Base64 string.

## Example

```vcl
declare local var.base64_encoded STRING;
set var.base64_encoded = digest.base64("Καλώς ορίσατε");
# var.base64_encoded is now "zprOsc67z47PgiDOv8+Bzq/Pg86xz4TOtQ=="
```
