base64 functions

base64.Encode

Encode data as a Base64 string. Specifically, this uses the standard Base64 encoding as defined in RFC4648 §4 (and not the URL-safe encoding).

Usage

base64.Encode input

Arguments

name description
input The data to encode. Can be a string, a byte array, or a buffer. Other types will be converted to strings first.

Examples

$ gomplate -i '{{ base64.Encode "hello world" }}'
aGVsbG8gd29ybGQ=
$ gomplate -i '{{ "hello world" | base64.Encode }}'
aGVsbG8gd29ybGQ=

base64.Decode

Decode a Base64 string. This supports both standard (RFC4648 §4) and URL-safe (RFC4648 §5) encodings.

This implementation outputs the data as a string, so it may not be appropriate for decoding binary data. If this functionality is desired, file an issue.

Usage

base64.Decode input

Arguments

name description
input The base64 string to decode

Examples

$ gomplate -i '{{ base64.Decode "aGVsbG8gd29ybGQ=" }}'
hello world
$ gomplate -i '{{ "aGVsbG8gd29ybGQ=" | base64.Decode }}'
hello world