github.com/wuhuizuo/gomplate@v3.5.0+incompatible/docs/content/functions/base64.md (about) 1 --- 2 title: base64 functions 3 menu: 4 main: 5 parent: functions 6 --- 7 8 9 ## `base64.Encode` 10 11 Encode data as a Base64 string. Specifically, this uses the standard Base64 encoding as defined in [RFC4648 §4](https://tools.ietf.org/html/rfc4648#section-4) (and _not_ the URL-safe encoding). 12 13 ### Usage 14 15 ```go 16 base64.Encode input 17 ``` 18 19 ### Arguments 20 21 | name | description | 22 |------|-------------| 23 | `input` | _(required)_ The data to encode. Can be a string, a byte array, or a buffer. Other types will be converted to strings first. | 24 25 ### Examples 26 27 ```console 28 $ gomplate -i '{{ base64.Encode "hello world" }}' 29 aGVsbG8gd29ybGQ= 30 ``` 31 ```console 32 $ gomplate -i '{{ "hello world" | base64.Encode }}' 33 aGVsbG8gd29ybGQ= 34 ``` 35 36 ## `base64.Decode` 37 38 Decode a Base64 string. This supports both standard ([RFC4648 §4](https://tools.ietf.org/html/rfc4648#section-4)) and URL-safe ([RFC4648 §5](https://tools.ietf.org/html/rfc4648#section-5)) encodings. 39 40 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](https://github.com/hairyhenderson/gomplate/issues/new). 41 42 ### Usage 43 44 ```go 45 base64.Decode input 46 ``` 47 48 ### Arguments 49 50 | name | description | 51 |------|-------------| 52 | `input` | _(required)_ The base64 string to decode | 53 54 ### Examples 55 56 ```console 57 $ gomplate -i '{{ base64.Decode "aGVsbG8gd29ybGQ=" }}' 58 hello world 59 ``` 60 ```console 61 $ gomplate -i '{{ "aGVsbG8gd29ybGQ=" | base64.Decode }}' 62 hello world 63 ```