fn decode(data string) []byte
decode decodes the base64 encoded string
value passed in data
. Please note: If you need to decode many strings repeatedly, take a look at decode_in_buffer
.
assert base64.decode('ViBpbiBiYXNlIDY0') == 'V in base 64'
fn decode_in_buffer(data &string, buffer &byte) int
decode_in_buffer decodes the base64 encoded string
reference passed in data
into buffer
. decode_in_buffer returns the size of the decoded data in the buffer. Please note: The buffer
should be large enough (i.e. 3/4 of the data.len, or larger) to hold the decoded data. Please note: This function does NOT allocate new memory, and is thus suitable for handling very large strings.
fn decode_str(data string) string
decode_str is the string variant of decode
fn encode(data []byte) string
encode encodes the []byte
value passed in data
to base64. Please note: base64 encoding returns a string
that is ~ 4/3 larger than the input. Please note: If you need to encode many strings repeatedly, take a look at encode_in_buffer
.
assert base64.encode('V in base 64') == 'ViBpbiBiYXNlIDY0'
fn encode_in_buffer(data []byte, buffer &byte) int
encode_in_buffer base64 encodes the []byte
passed in data
into buffer
. encode_in_buffer returns the size of the encoded data in the buffer. Please note: The buffer should be large enough (i.e. 4/3 of the data.len, or larger) to hold the encoded data. Please note: The function does NOT allocate new memory, and is suitable for handling very large strings.
fn encode_str(data string) string
encode_str is the string variant of encode
fn url_decode(data string) []byte
url_decode returns a decoded URL string
version of the a base64 url encoded string
passed in data
.
fn url_decode_str(data string) string
url_decode_str is the string variant of url_decode
fn url_encode(data []byte) string
url_encode returns a base64 URL encoded string
version of the value passed in data
.
fn url_encode_str(data string) string
url_encode_str is the string variant of url_encode