Sample code for 30+ languages & platforms
Unicode C++

Base64 Encode/Decode a String

See more Encryption Examples

_LANGUAGE_ example to base-64 encode and decode a string.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkBinDataW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkBinDataW bd;

    const wchar_t *s = L"A friend called me up the other day and talked about investing in a dot-com that sells lobsters. Internet lobsters. Where will this end? --Donald Trump";

    success = bd.AppendString(s,L"utf-8");

    const wchar_t *strBase64 = bd.getEncoded(L"base64");
    wprintf(L"%s\n",strBase64);

    // To decode:
    CkBinDataW bd2;
    bd2.AppendEncoded(strBase64,L"base64");

    const wchar_t *decoded = bd2.getString(L"utf-8");
    wprintf(L"%s\n",decoded);
    }