
#use wml::openssl-macros area=docs page=BIO_f_base64

<title>Documents, BIO_f_base64(3)</title>

<h1>BIO_f_base64(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#EXAMPLES">EXAMPLES</A>
	<LI><A HREF="#BUGS">BUGS</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
BIO_f_base64 - base64 BIO filter

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/bio.h&gt;
 \#include &lt;openssl/evp.h&gt;
</PRE>
<PRE> BIO_METHOD *   BIO_f_base64(void);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>BIO_f_base64()</CODE> returns the base64 BIO method. This is a filter
BIO that base64 encodes any data written through it and decodes any data
read through it.

</P>
<P>
Base64 BIOs do not support <CODE>BIO_gets()</CODE> or
<CODE>BIO_puts().</CODE> 

</P>
<P>
<CODE>BIO_flush()</CODE> on a base64 BIO that is being written through is
used to signal that no more data is to be encoded: this is used to flush
the final block through the BIO.

</P>
<P>
The flag BIO_FLAGS_BASE64_NO_NL can be set with
<CODE>BIO_set_flags()</CODE> to encode the data all on one line or expect
the data to be all on one line.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
Because of the format of base64 encoding the end of the encoded block
cannot always be reliably determined.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>BIO_f_base64()</CODE> returns the base64 BIO method.

</P>
<P>
<HR>
<H1><A NAME="EXAMPLES">EXAMPLES</A></H1>
<P>
Base64 encode the string ``Hello World\n'' and write the result to standard
output:

</P>
<PRE> BIO *bio, *b64;
 char message[] = &quot;Hello World \n&quot;;
</PRE>
<PRE> b64 = BIO_new(BIO_f_base64());
 bio = BIO_new_fp(stdout, BIO_NOCLOSE);
 bio = BIO_push(b64, bio);
 BIO_write(bio, message, strlen(message));
 BIO_flush(bio);
</PRE>
<PRE> BIO_free_all(bio);
</PRE>
<P>
Read Base64 encoded data from standard input and write the decoded data to
standard output:

</P>
<PRE> BIO *bio, *b64, *bio_out;
 char inbuf[512];
 int inlen;
</PRE>
<PRE> b64 = BIO_new(BIO_f_base64());
 bio = BIO_new_fp(stdin, BIO_NOCLOSE);
 bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
 bio = BIO_push(b64, bio);
 while((inlen = BIO_read(bio, inbuf, 512)) &gt; 0) 
        BIO_write(bio_out, inbuf, inlen);
</PRE>
<PRE> BIO_free_all(bio);
</PRE>
<P>
<HR>
<H1><A NAME="BUGS">BUGS</A></H1>
<P>
The ambiguity of EOF in base64 encoded data can cause additional data
following the base64 encoded block to be misinterpreted.

</P>
<P>
There should be some way of specifying a test that the BIO can perform to
reliably determine EOF (for example a MIME boundary).

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
TBA
</P>
:}

