Milan,

1K seems a lot to be missing.

I'm not sure about the line :

    outputSz = b64.encodeFinish(output, outLen - outputSz);

My reading is that outputSz could still be set from the last run through
the loop, and if the last piece of input was big enough, this would leave
no space in the output buffer for the final piece of output.
However that shoulnd't leave you with such a large amount missing.

How big is the file, and when you say you are missing 1K, are you sure it
is at the end (just to rule out the base64 encoder dropping bytes at the
end of buffers during each round).
Cheers,
     Berin

>
>       Is this OK:
>
> CString cEncodedFile;
> XSCryptCryptoBase64 b64;
> b64.encodeInit();
> CFile f;
> f.Open(cXMLFile.GetBuffer(999), CFile::modeRead);
> int outLen = 10 * 1024 * 4/3 + 4;
> BYTE *input = new BYTE[10 * 1024];
> BYTE *output = new BYTE[outLen];
> int inputSz = f.Read(input, 10 * 1024); int outputSz = 0;
>
> while (inputSz > 0) {
>       outputSz = b64.encode(input, inputSz, output, outLen );
>       CString tmp = CString((char*) output, outputSz);
>       cEncodedFile += tmp;
>       inputSz = f.Read(input, 10 * 1024);
> }
>
> outputSz = b64.encodeFinish(output, outLen - outputSz);
> //write_to_wherever(output, outputSz);
> CString tmp = CString((char*) output, outputSz);
> cEncodedFile += tmp;
>
> I'm missing 1K at the end. :(



Reply via email to