% limb manual
% base64_fmt(3)
% limb 0.1.0
% 2023-07-24
# NAME
base64_fmt, base64_scan - base64 encode/decode a byte array
# SYNOPSIS
#include <limb/base64.h>
```pre hl
size_t base64_fmt(char *<em>dst</em>, const void *<em>data</em>, size_t <em>dlen</em>, int <em>strict</em>)
ssize_t base64_scan(char *<em>dst</em>, const char *<em>data</em>, size_t <em>dlen</em>, int <em>strict</em>)
```
# DESCRIPTION
The `base64_fmt`() function will encode the byte array pointed to by `data` of
length `dlen` bytes into the byte array pointed to by `dst` using the base64
algorithm as described in [RFC 4648][rfc4648], unless `strict` is zero in which
case when padding is needed, only one padding character is used.
Refer to [base_fmt](3) for more details.
The `base64_scan`() function will decode the byte array pointed to by `data` of
length `dlen` into the byte array pointed to be `dst` using the base64 algorithm
as described in [RFC 4648][rfc4648], unless `strict` is zero if which case it
accepts a single padding character to indicate padding.
Refer to [base_scan](3) for more details.
[rfc4648]: https://datatracker.ietf.org/doc/html/rfc4648
# RETURN VALUE
The `base64_fmt`() function return the length written into `dst` - or that
would have been when `dst` is *NULL*.
The `base64_scan`() function return the length written into `dst` - or that
would have been when `dst` is *NULL* - on success. Otherwise it returns -1 and
sets `errno` to indicate the error.
# ERRORS
The `base64_scan`() function may fail for any of the errors described for
[base_scan](3) except *ERANGE*.
# SEE ALSO
[base32_fmt](3)