I would like to encode very small files (smaller than buffer) with base64. Yes I know, many base64 source codes available, but I would like to use OpenSSL.
My working example:
BIO *bin = BIO_new_file("smallfile.bin", "r");
BIO *b64 = BIO_new(BIO_f_base64());
BIO *bmem = BIO_new(BIO_s_mem());
BIO_push(b64, bmem);
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
char buff[8192];
int n=BIO_read(bin, buff, sizeof(buff));
BIO_write(b64, buff, n);
BIO_flush(b64);
n = BIO_read(bmem, buff, sizeof(buff));
cout << string(buff,n) << endl;
BIO_free_all(bin);
BIO_free_all(b64);
How can I make chain directly instead read/write BIOs, like: BIO_f_new_file -> BIO_f_base64 -> buffer or BIO_s_mem
It's possible?