On Thu, 20 Nov 2008 10:13:34 +0100, anon <anon@no.invalidwrote:
Quote:
>Chunekit Pong wrote:
Quote:
>What's the problem with this code?
>>
>
>It doesn't compile
>
Quote:
>the purpose is to convert binary file into a Base64 string
>>
>
>What's Base64 string?
>
Quote:
>I seem to have problem in the following line
> BYTE const* pbBinary = &bytes[0];
> int size = sizeof(pbBinary);
>>
>
>Most likely you will get 4 (depends on the platform you use)
>
Quote:
>=================
> typedef unsigned char BYTE;
> std::ifstream file1("c:/test2.png");
>>
> // read from test2.png into BYTE array
> std::vector<BYTEbytes(
> (std::istreambuf_iterator<char>(file1))
> , (std::istreambuf_iterator<char>())
> );
>
>Is this working?
>
Quote:
> if(bytes.empty())
> ; // no bytes have been read
>>
> BYTE const* pbBinary = &bytes[0];
> int size = sizeof(pbBinary);
>>
>
>I would do this:
>const int size = bytes.size();
I used the bytes.size();
but i found that - pEncOut - is not holding any string after calling
CryptBinaryToString function, when I debug it says bad Prt something.
After calling the function CryptBinaryToString - pEncOut shoul have
the Base64 string generated.
===================
char *pEncOut = NULL;
BOOL fRet = ::CryptBinaryToString( pbBinary, size,
CRYPT_STRING_BASE64, pEncOut, &ulEncLen );