1BIO_F_BASE64(3)                     OpenSSL                    BIO_F_BASE64(3)
2
3
4

NAME

6       BIO_f_base64 - base64 BIO filter
7

SYNOPSIS

9        #include <openssl/bio.h>
10        #include <openssl/evp.h>
11
12        const BIO_METHOD *BIO_f_base64(void);
13

DESCRIPTION

15       BIO_f_base64() returns the base64 BIO method. This is a filter BIO that
16       base64 encodes any data written through it and decodes any data read
17       through it.
18
19       Base64 BIOs do not support BIO_gets() or BIO_puts().
20
21       BIO_flush() on a base64 BIO that is being written through is used to
22       signal that no more data is to be encoded: this is used to flush the
23       final block through the BIO.
24
25       The flag BIO_FLAGS_BASE64_NO_NL can be set with BIO_set_flags() to
26       encode the data all on one line or expect the data to be all on one
27       line.
28

NOTES

30       Because of the format of base64 encoding the end of the encoded block
31       cannot always be reliably determined.
32

RETURN VALUES

34       BIO_f_base64() returns the base64 BIO method.
35

EXAMPLES

37       Base64 encode the string "Hello World\n" and write the result to
38       standard output:
39
40        BIO *bio, *b64;
41        char message[] = "Hello World \n";
42
43        b64 = BIO_new(BIO_f_base64());
44        bio = BIO_new_fp(stdout, BIO_NOCLOSE);
45        BIO_push(b64, bio);
46        BIO_write(b64, message, strlen(message));
47        BIO_flush(b64);
48
49        BIO_free_all(b64);
50
51       Read Base64 encoded data from standard input and write the decoded data
52       to standard output:
53
54        BIO *bio, *b64, *bio_out;
55        char inbuf[512];
56        int inlen;
57
58        b64 = BIO_new(BIO_f_base64());
59        bio = BIO_new_fp(stdin, BIO_NOCLOSE);
60        bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
61        BIO_push(b64, bio);
62        while ((inlen = BIO_read(b64, inbuf, 512)) > 0)
63            BIO_write(bio_out, inbuf, inlen);
64
65        BIO_flush(bio_out);
66        BIO_free_all(b64);
67

BUGS

69       The ambiguity of EOF in base64 encoded data can cause additional data
70       following the base64 encoded block to be misinterpreted.
71
72       There should be some way of specifying a test that the BIO can perform
73       to reliably determine EOF (for example a MIME boundary).
74
76       Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
77
78       Licensed under the OpenSSL license (the "License").  You may not use
79       this file except in compliance with the License.  You can obtain a copy
80       in the file LICENSE in the source distribution or at
81       <https://www.openssl.org/source/license.html>.
82
83
84
851.1.1                             2018-09-11                   BIO_F_BASE64(3)
Impressum