Click here to Skip to main content
15,884,937 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;
}


[edit]Code block moved to cover code only - OriginalGriff[/edit]
Posted
Updated 20-Apr-11 2:19am
v4

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900