1 2 3 4 5 6 7 8 9 10 11 12 13 14 | BOOL ToBase64(BYTE *pInput, int pInputLen, BYTE **pOutput, DWORD *pOutputLen) { BOOL lRetVal = FALSE; DWORD lBufSize = 0; if (CryptBinaryToStringA(pInput, pInputLen, CRYPT_STRING_BASE64, NULL, &lBufSize) && lBufSize > 0) if ((*pOutput = (BYTE *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lBufSize+1)) != NULL) if (CryptBinaryToStringA(pInput, pInputLen, CRYPT_STRING_BASE64, (LPSTR) *pOutput, &lBufSize)) lRetVal = TRUE; *pOutputLen = lBufSize; return(lRetVal); } |