1=pod 2 3=head1 NAME 4 5BIO_f_base64 - base64 BIO filter 6 7=head1 SYNOPSIS 8 9 #include <openssl/bio.h> 10 #include <openssl/evp.h> 11 12 BIO_METHOD * BIO_f_base64(void); 13 14=head1 DESCRIPTION 15 16BIO_f_base64() returns the base64 BIO method. This is a filter 17BIO that base64 encodes any data written through it and decodes 18any data read through it. 19 20Base64 BIOs do not support BIO_gets() or BIO_puts(). 21 22BIO_flush() on a base64 BIO that is being written through is 23used to signal that no more data is to be encoded: this is used 24to flush the final block through the BIO. 25 26The flag BIO_FLAGS_BASE64_NO_NL can be set with BIO_set_flags() 27to encode the data all on one line or expect the data to be all 28on one line. 29 30=head1 NOTES 31 32Because of the format of base64 encoding the end of the encoded 33block cannot always be reliably determined. 34 35=head1 RETURN VALUES 36 37BIO_f_base64() returns the base64 BIO method. 38 39=head1 EXAMPLES 40 41Base64 encode the string "Hello World\n" and write the result 42to standard output: 43 44 BIO *bio, *b64; 45 char message[] = "Hello World \n"; 46 47 b64 = BIO_new(BIO_f_base64()); 48 bio = BIO_new_fp(stdout, BIO_NOCLOSE); 49 BIO_push(b64, bio); 50 BIO_write(b64, message, strlen(message)); 51 BIO_flush(b64); 52 53 BIO_free_all(b64); 54 55Read Base64 encoded data from standard input and write the decoded 56data to standard output: 57 58 BIO *bio, *b64, *bio_out; 59 char inbuf[512]; 60 int inlen; 61 62 b64 = BIO_new(BIO_f_base64()); 63 bio = BIO_new_fp(stdin, BIO_NOCLOSE); 64 bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); 65 BIO_push(b64, bio); 66 while((inlen = BIO_read(b64, inbuf, 512)) > 0) 67 BIO_write(bio_out, inbuf, inlen); 68 69 BIO_flush(bio_out); 70 BIO_free_all(b64); 71 72=head1 BUGS 73 74The ambiguity of EOF in base64 encoded data can cause additional 75data following the base64 encoded block to be misinterpreted. 76 77There should be some way of specifying a test that the BIO can perform 78to reliably determine EOF (for example a MIME boundary). 79 80=head1 SEE ALSO 81 82TBA 83