github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/website/docs/language/functions/base64encode.html.md (about) 1 --- 2 layout: "language" 3 page_title: "base64encode - Functions - Configuration Language" 4 sidebar_current: "docs-funcs-encoding-base64encode" 5 description: |- 6 The base64encode function applies Base64 encoding to a string. 7 --- 8 9 # `base64encode` Function 10 11 `base64encode` applies Base64 encoding to a string. 12 13 Terraform uses the "standard" Base64 alphabet as defined in 14 [RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4). 15 16 Strings in the Terraform language are sequences of unicode characters rather 17 than bytes, so this function will first encode the characters from the string 18 as UTF-8, and then apply Base64 encoding to the result. 19 20 The Terraform language applies Unicode normalization to all strings, and so 21 passing a string through `base64decode` and then `base64encode` may not yield 22 the original result exactly. 23 24 While we do not recommend manipulating large, raw binary data in the Terraform 25 language, Base64 encoding is the standard way to represent arbitrary byte 26 sequences, and so resource types that accept or return binary data will use 27 Base64 themselves, and so this function exists primarily to allow string 28 data to be easily provided to resource types that expect Base64 bytes. 29 30 `base64encode` is, in effect, a shorthand for calling 31 [`textencodebase64`](./textencodebase64.html) with the encoding name set to 32 `UTF-8`. 33 34 ## Examples 35 36 ``` 37 > base64encode("Hello World") 38 SGVsbG8gV29ybGQ= 39 ``` 40 41 ## Related Functions 42 43 * [`base64decode`](./base64decode.html) performs the opposite operation, 44 decoding Base64 data and interpreting it as a UTF-8 string. 45 * [`textencodebase64`](./textencodebase64.html) is a more general function that 46 supports character encodings other than UTF-8. 47 * [`base64gzip`](./base64gzip.html) applies gzip compression to a string 48 and returns the result with Base64 encoding all in one operation. 49 * [`filebase64`](./filebase64.html) reads a file from the local filesystem 50 and returns its raw bytes with Base64 encoding, without creating an 51 intermediate Unicode string.