I have this buffer given: unsigned char *buffer; int buffer_length;
This is how I currently convert it to a base64-encoded buffer: --------------------------- BIO *mem = BIO_new(BIO_s_mem()); BIO *b64 = BIO_new(BIO_f_base64()); mem = BIO_push(b64, mem); int write_length = BIO_write(mem, buffer, buffer_length); if (write_length != buffer_length) //* return -1; int flush_result = BIO_flush(mem); if (flush_result != 1) return -1; unsigned char *result; //** int result_length = BIO_get_mem_data(mem, &result); //use the base64-encoded result to do whatever I need to do BIO_free_all(mem); return 0; --------------------------- So far, this seems to be working. However, is this good and robust code? I have particular questions about the code pieces marked with asterisks above: *: Is it correct to assume that BIO_write() will always write out the whole base64 encoded string at once, or do I have to create a loop here? **: Is it correct to have the type "unsigned char*" or must I use "char *" instead? -- View this message in context: http://old.nabble.com/How-to-properly-base64-encode-a-buffer-tp32995002p32995002.html Sent from the OpenSSL - User mailing list archive at Nabble.com. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org