To reproduce this result from Wikipedia base64 article:
To base64 encode this string
"Input ends with: any carnal pleasure."
and get this result:
"YW55IGNhcm5hbCBwbGVhc3VyZS4="
Which function should I use?
I tried to assign the input string to a BYTE array and use
CryptBinaryToStringA, but it returns a totally different string.
Thank you!
BOOL base64(char **tch) { DWORD len = 0; BYTE byteArr[] = "Input ends with: any carnal pleasure."; DWORD BUFF_LEN = ARRAYSIZE(byteArr); // calculate the required buffer length res = CryptBinaryToStringA(byteArr, BUFF_LEN, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, NULL, &len); if (res == FALSE) { reportError(_T("allocateBuffer"), GetLastError()); return FALSE; } // do it if(len == 0) { reportError(_T("length"), 0); return FALSE; } *tch = new char[len]; res = CryptBinaryToStringA(byteArr, BUFF_LEN, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, *tch, &len); if (res == FALSE) { reportError(_T("encrypt"), GetLastError()); return FALSE; } return TRUE; }