If you need convert to/from Base64 in your C/C++ project you can do that using openssl functions.

Convert to Base64

unsigned char *base64(const unsigned char *input, int length)
{
    BIO *bmem, *b64;
    BUF_MEM *bptr;
    b64 = BIO_new(BIO_f_base64());
    bmem = BIO_new(BIO_s_mem());
    b64 = BIO_push(b64, bmem);
    BIO_write(b64, input, length);
    BIO_flush(b64);
    BIO_get_mem_ptr(b64, &bptr);
    unsigned char *buff = (unsigned char *) malloc(bptr->length);
    memcpy(buff, bptr->data, bptr->length - 1);
    buff[bptr->length - 1] = 0;
    BIO_free_all(b64);
    return buff;
}

You can call base64 as:

unsigned char *buff;
// ...
// allocate buff with the byes you need to convert to Base64
// ...
int buff_len;
// ...
// set buff_len with the size of buff
// ...
unsigned char *b64_buff = base64(buff, buff_len);

The result b64_buff will be NULL terminated. Because of the memory allocation is inside base64(...) you must remember to call "free" when you don't need b64_buff anymore.

Convert from Base64

unsigned char *unbase64(unsigned char *input, int length, int *unbase_len)
{
    BIO *b64, *bmem;
    unsigned char *buff = (unsigned char *)malloc(length);
    memset(buff, 0, length);
    b64 = BIO_new(BIO_f_base64());
    BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
    bmem = BIO_new_mem_buf(input, length);
    bmem = BIO_push(b64, bmem);
    *unbase_len = BIO_read(bmem, buff, length);
    BIO_free_all(bmem);
    return buff;
}

You can call unbase64 as:

unsigned char *b64_buff;
// ...
// allocate b64_buff with the byes you need to convert from Base64
// ...
int b64_buff_len;
// ...
// set b64_buff_len with the size of b64_buff
// ...
int buff_len=0;
unsigned char *buff = unbase64(b64_buff, b64_buff_len, &buff_len);

You will get the buff pointer as return and buff_len will be written with it's lenght. Because of the memory allocation is inside unbase64(...) you must remember to call "free" when you don't need buff anymore.