The Base64 text of the bytes in input, using the 64 symbols in table.
base64_encode :: (
input: string,
table: string = BASE64_ENCODER_TABLE,
pad := true
) -> string
With pad set (the default) the text ends in = so its length is a multiple of 4; without it the
last group is left short. Empty input gives an empty string. table must hold exactly 64 bytes,
or an assert fails.
The result is allocated with the context allocator. The caller frees it.
Parameters
- input: string
- table: string
- pad := true
Returns
- string
encoded := base64_encode("Man");
defer free(encoded);
assert(encoded == "TWFu");
padded := base64_encode("Ma");
defer free(padded);
assert(padded == "TWE=");
bare := base64_encode("Ma", pad = false);
defer free(bare);
assert(bare == "TWE");