dmi_base64_encode
Synopsis
#include <opendmi/utils/base64.h>
char *dmi_base64_encode(
const dmi_data_t *data,
size_t data_length,
size_t *poutput_length);
Description
The dmi_base64_encode function encodes binary data into a Base64 string.
The function allocates and returns a null-terminated Base64-encoded string representing the given binary buffer. The caller is responsible for freeing the returned buffer.
Return value
On success, returns a newly allocated null-terminated Base64 string. On
failure, returns nullptr (e.g., allocation error or invalid arguments).
Examples
const dmi_data_t input[] = { 0x48, 0x65, 0x6C, 0x6C, 0x6F };
size_t output_length;
char *encoded = dmi_base64_encode(input, sizeof(input), &output_length);
if (encoded != nullptr) {
printf("encoded: %s (length: %zu)\n", encoded, output_length);
free(encoded);
}