rapidyaml  0.7.0
parse and emit YAML, and do it fast
Base64 encoding/decoding

Functions

bool c4::base64_valid (csubstr encoded)
 check that the given buffer is a valid base64 encoding More...
 
size_t c4::base64_encode (substr encoded, cblob data)
 base64-encode binary data. More...
 
size_t c4::base64_decode (csubstr encoded, blob data)
 decode the base64 encoding in the given buffer More...
 

Detailed Description

See also
https://en.wikipedia.org/wiki/Base64
https://www.base64encode.org/

Function Documentation

◆ base64_valid()

bool c4::base64_valid ( csubstr  encoded)

check that the given buffer is a valid base64 encoding

See also
https://en.wikipedia.org/wiki/Base64

◆ base64_encode()

size_t c4::base64_encode ( substr  encoded,
cblob  data 
)

base64-encode binary data.

Parameters
encoded[out] output buffer for encoded data
data[in] the input buffer with the binary data
Returns
the number of bytes needed to return the output (ie the required size for encoded). No writes occur beyond the end of the output buffer, so it is safe to do a speculative call where the encoded buffer is empty, or maybe too small. The caller should ensure that the returned size is smaller than the size of the encoded buffer.
Note
the result depends on endianness. If transfer between little/big endian systems is desired, the caller should normalize data before encoding.
See also
https://en.wikipedia.org/wiki/Base64

Referenced by c4::to_chars().

◆ base64_decode()

size_t c4::base64_decode ( csubstr  encoded,
blob  data 
)

decode the base64 encoding in the given buffer

Parameters
encoded[in] the encoded base64
data[out] the output buffer
Returns
the number of bytes needed to return the output (ie the required size for data). No writes occur beyond the end of the output buffer, so it is safe to do a speculative call where the data buffer is empty, or maybe too small. The caller should ensure that the returned size is smaller than the size of the data buffer.
Note
the result depends on endianness. If transfer between little/big endian systems is desired, the caller should normalize data after decoding.
See also
https://en.wikipedia.org/wiki/Base64

Referenced by c4::from_chars(), and sample::sample_base64().