.\" Copyright (c) 2022 The DragonFly Project. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in .\" the documentation and/or other materials provided with the .\" distribution. .\" 3. Neither the name of The DragonFly Project nor the names of its .\" contributors may be used to endorse or promote products derived .\" from this software without specific, prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .Dd May 1, 2022 .Dt BASE64 3 .Os .Sh NAME .Nm base64 , .Nm b64_ntop , .Nm b64_pton .Nd base64 encode and decode .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In resolv.h .Ft int .Fo b64_ntop .Fa "const unsigned char *src" .Fa "size_t srclength" .Fa "char *target" .Fa "size_t targsize" .Fc .Ft int .Fo b64_pton .Fa "const char *src" .Fa "unsigned char *target" .Fa "size_t targsize" .Fc .Sh DESCRIPTION .Fn B64_ntop encodes the input data .Fa src of length .Fa srclength , and writes the encoded string to .Fa target of capacity .Fa targsize . The output buffer .Fa target should be big enough to hold the encoded string, including the terminating NUL character. On success, .Fa target holds the encoded string and its length (without accounting for the NUL terminator) is returned. Otherwise, a value of \-1 is returned. .Pp .Fn B64_pton decodes the base64 string .Fa src and writes the decoded data to .Fa target of capacity .Fa targsize . On success, .Fa target holds the decoded data and its length is returned. Otherwise, a value of \-1 is returned. If the output buffer .Fa target is .Dv NULL , .Fn b64_pton returns the required length to hold the decoded data. .Sh RETURN VALUES The .Nm base64 functions return the length of the result if successful; otherwise the value \-1 is returned. .Sh SEE ALSO .Xr openssl 1 .Rs .%R RFC .%N 1521 .%D September 1993 .%T "MIME (Multipurpose Internet Mail Extensions) Part One" .Re .Sh HISTORY The .Nm base64 functions appeared in .Fx 3.0 . .Sh AUTHORS .An -nosplit This manual page was written by .An Aaron LI Aq Mt aly@aaronly.me .