Conversion of RSA Encrypted message to Base64 format !!!

2011-04-20 Thread pattabi raman
Hi,

I have done the RSA encryption program. Now I want to convert that encrypted
message to BASE64 message inorder to send the message via socket.
I am trying the following sample code which converts Hello World to Base64
format and *printing in console* ( stdout).

*How can I use the funtion BIO_new_fp(stdout, BIO_NOCLOSE) to print the
value to another character array instead of stdout? If not this,
which Bio_ function I can use so that it will convert to Base64 and put it
in char buffer ?? *
**
#include stdio.h
#include openssl/bio.h
#include openssl/evp.h

int main(int argc, char *argv[])
{
 printf(Hello, world\n);
 BIO *bio, *b64;
 char message[] = Hello World \n;
  b64 = BIO_new(BIO_f_base64());
 bio = BIO_new_fp(stdout, BIO_NOCLOSE);
 //bio = BIO_new_mem_buf(
 bio = BIO_push(b64, bio);
 BIO_write(bio, message, strlen(message));
 BIO_flush(bio);
 BIO_free_all(bio);

 return 0;
}

Thanks,
Pattabi.


Re: Conversion of RSA Encrypted message to Base64 format !!!

2011-04-20 Thread Wim Lewis

On 20 Apr 2011, at 3:01 AM, pattabi raman wrote:
 How can I use the funtion BIO_new_fp(stdout, BIO_NOCLOSE) to print the 
 value to another character array instead of stdout? If not this, which Bio_ 
 function I can use so that it will convert to Base64 and put it in char 
 buffer ?? 

I think you want to use a memory BIO, e.g. BIO_new(BIO_s_mem()).

If your C library has the funopen() call, you could use that to write to a 
memory buffer using BIO_new_fp(), but that seems silly. :)


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org