BASE64 encoding and decoding.
More...
|
VTM_API int | vtm_base64_encode (const void *input, size_t len, void *buf, size_t buf_len) |
|
VTM_API int | vtm_base64_decode (const void *input, size_t len, void *buf, size_t *buf_len) |
|
#define VTM_BASE64_ENC_BUF_LEN |
( |
|
INPUT_LEN | ) |
(4 * (((INPUT_LEN) + 2) / 3) + 1) |
Calculates the necessary buffer size for encoding.
- Parameters
-
INPUT_LEN | the input length |
#define VTM_BASE64_DEC_BUF_LEN |
( |
|
INPUT_LEN | ) |
(((INPUT_LEN) / 4) * 3) |
Calculates the necessary buffer size for decoding.
- Parameters
-
INPUT_LEN | length of BASE64 string |
VTM_API int vtm_base64_encode |
( |
const void * |
input, |
|
|
size_t |
len, |
|
|
void * |
buf, |
|
|
size_t |
buf_len |
|
) |
| |
Encodes a memory chunk into BASE64 format.
The output is written including a final NUL-terminator.
- Parameters
-
input | pointer to input memory |
len | size of input |
buf | preallocated buffer where BASE64 string will be written to |
buf_len | size of buffer |
- Returns
- VTM_OK if encoding was successful
-
VTM_E_INVALID_ARG if one of the supplied arguments is invalid, for example a too small buffer
VTM_API int vtm_base64_decode |
( |
const void * |
input, |
|
|
size_t |
len, |
|
|
void * |
buf, |
|
|
size_t * |
buf_len |
|
) |
| |
Decodes a BASE64 string.
- Parameters
-
| input | pointer to begin of BASE64 string |
| len | length of input string |
| buf | preallocated buffer where decoded data will be written to |
[in,out] | buf_len | size of buffer, overwritten with used buffer size |
- Returns
- VTM_OK if decoding was successful
-
VTM_E_INVALID_ARG if one of the supplied arguments is invalid, for example a too small buffer