base64
Function
base64 — encode/decode Base64 strings
Synopsis
base64(b: bytes) -> string
base64(s: string) -> bytes
Description
The base64 function encodes a bytes value b
as a
a Base64 string,
or decodes a Base64 string s
into a bytes value.
Examples
Encode byte sequence 0x010203
into its Base64 string:
echo '0x010203' | super -z -c 'yield base64(this)' -
=>
"AQID"
Decode "AQID" into byte sequence 0x010203
:
echo '"AQID"' | super -z -c 'yield base64(this)' -
=>
0x010203
Encode ASCII string into Base64-encoded string:
echo '"hello, world"' | super -z -c 'yield base64(bytes(this))' -
=>
"aGVsbG8sIHdvcmxk"
Decode a Base64 string and cast the decoded bytes to a string:
echo '"aGVsbG8gd29ybGQ="' | super -z -c 'yield string(base64(this))' -
=>
"hello world"