Files
Packer-Cn/website/content/docs/templates/hcl_templates/functions/encoding/base64encode.mdx
T
50da6c8dc8 docs: Migrate link formats (#12192)
* Adding check-legacy-links-format workflow

* Adding test-link-rewrites workflow

* Migrating links to new format

* Updating docs-content-check-legacy-links-format hash

* chore: update source

* Update generated partials from Packer plugin SDK

* Bump packer-plugin-sdk to get latest packer-sdc

* Update website/content/docs/templates/hcl_templates/blocks/build/provisioner.mdx

* Update Plugin SDK to fix shell-local regression

---------

Co-authored-by: Kendall Strautman <[email protected]>
Co-authored-by: Wilken Rivera <[email protected]>
Co-authored-by: Kendall Strautman <[email protected]>
2023-01-27 09:47:08 -08:00

38 lines
1.4 KiB
Plaintext

---
page_title: base64encode - Functions - Configuration Language
description: The base64encode function applies Base64 encoding to a string.
---
# `base64encode` Function
`base64encode` applies Base64 encoding to a string.
Packer uses the "standard" Base64 alphabet as defined in
[RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
Strings in the Packer language are sequences of unicode characters rather
than bytes, so this function will first encode the characters from the string
as UTF-8, and then apply Base64 encoding to the result.
The Packer language applies Unicode normalization to all strings, and so
passing a string through `base64decode` and then `base64encode` may not yield
the original result exactly.
While we do not recommend manipulating large, raw binary data in the Packer
language, Base64 encoding is the standard way to represent arbitrary byte
sequences, and so resource types that accept or return binary data will use
Base64 themselves, and so this function exists primarily to allow string
data to be easily provided to resource types that expect Base64 bytes.
## Examples
```shell-session
> base64encode("Hello World")
SGVsbG8gV29ybGQ=
```
## Related Functions
- [`base64decode`](/packer/docs/templates/hcl_templates/functions/encoding/base64decode) performs the opposite operation,
decoding Base64 data and interpreting it as a UTF-8 string.