Well, I know that this was asked earlier, but after searching I could not find the correct answer.
I need to convert the buffer (unsigned char *) to base64, the base64 function I use takes as parameters:
void Base64Enc(const unsigned char *src, int srclen, unsigned char *dest)
where int srclenis the length of the string src.
My question is: how do I get the length of my buffer. No, it is not canceled. No, I do not want sizeof(BYTE). I just need to know what to pass as srclen, so I can convert this buffer to base64.
EDIT
Here is the code showing what I'm doing:
unsigned char *pBytes;
unsigned char *B64Encoded;
int b64size = 0;
if (pBytes = (unsigned char *) GlobalLock(hMem))
{
DWORD size = (DWORD)GlobalSize(hMem);
b64size = size / sizeof(unsigned char);
Base64Enc(pBytes, b64size, B64Encoded);
if (fp = fopen("ububub.txt", "wb"))
{
printf("data: %s\n", B64Encoded);
fwrite(B64Encoded, strlen(B64Encoded), 1, fp);
fclose(fp);
}
}
source
share