5 BIO_f_base64 - base64 BIO filter
7 =for comment multiple includes
11 #include <openssl/bio.h>
12 #include <openssl/evp.h>
14 const BIO_METHOD *BIO_f_base64(void);
18 BIO_f_base64() returns the base64 BIO method. This is a filter
19 BIO that base64 encodes any data written through it and decodes
20 any data read through it.
22 Base64 BIOs do not support BIO_gets() or BIO_puts().
24 BIO_flush() on a base64 BIO that is being written through is
25 used to signal that no more data is to be encoded: this is used
26 to flush the final block through the BIO.
28 The flag BIO_FLAGS_BASE64_NO_NL can be set with BIO_set_flags()
29 to encode the data all on one line or expect the data to be all
34 Because of the format of base64 encoding the end of the encoded
35 block cannot always be reliably determined.
39 BIO_f_base64() returns the base64 BIO method.
43 Base64 encode the string "Hello World\n" and write the result
47 char message[] = "Hello World \n";
49 b64 = BIO_new(BIO_f_base64());
50 bio = BIO_new_fp(stdout, BIO_NOCLOSE);
52 BIO_write(b64, message, strlen(message));
57 Read Base64 encoded data from standard input and write the decoded
58 data to standard output:
60 BIO *bio, *b64, *bio_out;
64 b64 = BIO_new(BIO_f_base64());
65 bio = BIO_new_fp(stdin, BIO_NOCLOSE);
66 bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
68 while((inlen = BIO_read(b64, inbuf, 512)) > 0)
69 BIO_write(bio_out, inbuf, inlen);
76 The ambiguity of EOF in base64 encoded data can cause additional
77 data following the base64 encoded block to be misinterpreted.
79 There should be some way of specifying a test that the BIO can perform
80 to reliably determine EOF (for example a MIME boundary).
84 Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
86 Licensed under the OpenSSL license (the "License"). You may not use
87 this file except in compliance with the License. You can obtain a copy
88 in the file LICENSE in the source distribution or at
89 L<https://www.openssl.org/source/license.html>.