Encoding Utilities =================== | **Headers:** ``lwip/cryptography/base64.h``, ``lwip/cryptography/bytes.h`` | **References:** `RFC 4648 `_ — Base64 ``lwip/cryptography/base64.h`` — Base64 encode/decode ------------------------------------------------------ Standard Base64 (RFC 4648) with ``+``/``/`` alphabet and ``=`` padding. Both functions return the number of bytes written. Output buffer sizing: encode output is ``4 * ((input_len + 2) / 3)`` bytes; decode output is at most ``input_len * 3 / 4`` bytes. .. c:function:: size_t tls_base64_encode(const uint8_t *inbuf, size_t len, uint8_t *outbuf) Encode binary data as Base64. :param inbuf: Input binary data. :param len: Length of input in bytes. :param outbuf: Output buffer (at least ``4 * ((len + 2) / 3)`` bytes). :returns: Number of bytes written to ``outbuf``. .. c:function:: size_t tls_base64_decode(const uint8_t *inbuf, size_t len, uint8_t *outbuf) Decode Base64 data to binary. :param inbuf: Base64-encoded input. :param len: Length of input in bytes. :param outbuf: Output buffer (at least ``len * 3 / 4`` bytes). :returns: Number of bytes written to ``outbuf``. .. code-block:: c uint8_t encoded[512]; size_t enc_len = tls_base64_encode(binary, bin_len, encoded); uint8_t decoded[256]; size_t dec_len = tls_base64_decode(encoded, enc_len, decoded);