Hi,
I'm trying to use BIO to do base64 encoding.
but here's the problem
in the sample code below,
if I comment out like <<<< 1 (which uses mem bio) and uncomment <<<<2 (one
that uses file bio)
everything works and the encoded string is written the std out.
Which is good as it tells me that things are working fine.
But what i really want is the encoded string in a char buffer.
And so i comment out <<<< 2 and use <<<< 1 instead. As its suppose to write
the encoded string into a buffer,
but the problem here is pEncBuf is empty even though bytesWritten says it
wrote 4 bytes.
And i can't explain why it won't work.
So to sum it up
file Bio works and mem bio doesn't.
If any one of you have any ideas please let me know.
thanks !
/// code
int b64encode(const char *pPlainText, int pSize, char *pEncBuf, unsigned int
*pEncSize);
int main(int argc, char *argv[])
{
char ch[] = "adsf";
char enc[128];
int encSize= 0;
b64encode(ch, strlen(ch), enc, &encSize);
printf("[%s]", enc);
}
int b64encode(const char *pPlainText, int pSize, char *pEncBuf, unsigned int
*pEncSize)
{
BIO *bio, *b64;
b64 = BIO_new(BIO_f_base64 ());
bio = BIO_new_mem_buf(pEncBuf, *pEncSize); <<<<< 1
//bio = BIO_new_fp (stdout, BIO_NOCLOSE); <<<<< 2
BIO_push (b64, bio);
int bytesWritten = BIO_write(b64, pPlainText, pSize);
printf("Bytes Written %d, %s\n", bytesWritten, *pEncBuf);
BIO_flush (bio);
BIO_free_all (bio);
return bytesWritten;
}
/// code ends
_________________________________________________________________
http://newlivehotmail.com
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager [EMAIL PROTECTED]