Click here to Skip to main content
14,640,651 members
Rate this:
Please Sign up or sign in to vote.
See more:

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));

 return 0;

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

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100