# mco_lews_base64_encode
RT

### Prototype

        MCO_RET mco_lews_base64_encode(
            mco_uint1 *in_str,
            mco_size_t in_size,
            char *out_str,
            mco_size_t out_size
        );

### Arguments

`in_str`
Pointer to the input buffer containing binary data to encode.
`in_size`
Size (in bytes) of the input buffer.
`out_str`
Output buffer where the Base64-encoded null-terminated string will be stored.
`out_size`
Size (in bytes) of the output buffer, including space for the null terminator.

### Description

> This function encodes binary data from `in_str` into a Base64-encoded string and stores the result in `out_str`.

> The output is a standard Base64 string (using characters A–Z, a–z, 0–9, '+', '/') without line breaks, and it is null-terminated.

> The required size of the output buffer must be at least `4 * ((in_size + 2) / 3) + 1` bytes to accommodate the encoded string and the null terminator.

>         #define SHA1_DIGEST_SIZE 20
>         ...
>         MCO_RET rc;
>         mco_uint1 sha1_buf[SHA1_DIGEST_SIZE];
>         char base64_buf[29];  // 4 * ((20 + 2) / 3) + 1 = 28 + 1 = 29

>         ...
>         rc = mco_lews_base64_encode(sha1_buf, SHA1_DIGEST_SIZE, base64_buf, sizeof(base64_buf));
>         ...

### Return Codes

`MCO_S_OK`
Data successfully encoded.
`MCO_E_LEWS_NO_ENOUGH_MEMORY`
The output buffer is too small to hold the Base64-encoded string (including the null terminator).

### Files

Header file:
mcoewslite.h
Source file:
mcoewslite.c
Library:
mcoewslite.a