2 .TH base64 3 "20 June 1999" "Straylight/Edgeware" "mLib utilities library"
4 base64, base32, hex \- obsolete binary encoding functions
16 .B "#include <mLib/base64.h>"
17 .B "#include <mLib/base32.h>"
18 .B "#include <mLib/hex.h>"
21 .B "\h'4n'char *indent;"
22 .B "\h'4n'unsigned maxline;"
26 .BI "void base64_encode(base64_ctx *" ctx ,
27 .BI " const void *" p ", size_t " sz ,
29 .BI "void base64_decode(base64_ctx *" ctx ,
30 .BI " const void *" p ", size_t " sz ,
32 .BI "void base64_init(base64_ctx *" ctx );
35 .B "\h'4n'char *indent;"
36 .B "\h'4n'unsigned maxline;"
40 .BI "void base32_encode(base32_ctx *" ctx ,
41 .BI " const void *" p ", size_t " sz ,
43 .BI "void base32_decode(base32_ctx *" ctx ,
44 .BI " const void *" p ", size_t " sz ,
46 .BI "void base32_init(base32_ctx *" ctx );
49 .B "\h'4n'char *indent;"
50 .B "\h'4n'unsigned maxline;"
54 .BI "void hex_encode(hex_ctx *" ctx ,
55 .BI " const void *" p ", size_t " sz ,
57 .BI "void hex_decode(hex_ctx *" ctx ,
58 .BI " const void *" p ", size_t " sz ,
60 .BI "void hex_init(hex_ctx *" ctx );
68 functions perform encoding and decoding of arbitrary binary strings, as
69 defined by RFC4648, but without error reporting. These functions are
70 obsolete, and new applications should use the
72 interface, which provides more encoding and decoding options, and proper
75 The interfaces to these sets of functions is very similar: in
76 the following description,
84 Before encoding or decoding a string, a
88 must be initialized, by passing it to
90 The context contains data which must be retained between calls to encode
91 or decode substrings. The
93 function sets up initial values for the data, and sets up defaults for
94 the output formatting settings (see below).
96 Encoding of a string is performed by the
98 function. It is passed a pointer to a context block
100 the input substring to encode passed by address
104 and a pointer to a dynamic string
106 in which to write its output (see
108 for details on dynamic strings). Once all the input data has been
111 it is necessary to flush the final few bytes of output. This is
114 a null pointer as its source argument. It is an error to attempt to
115 continue encoding after flushing output.
119 function is formatted into lines using values from the context
122 member is a pointer to a null-terminated string which is used to
123 separate the output lines. The default indent string contains only a
124 newline character. The
126 member gives the maximum length of line that
128 is allowed to produce. If this is not a multiple of 4, it is rounded
129 up to the next highest multiple of four before use. A value of zero
132 not to perform line splitting: the output will be a single (possibly
133 very long) output line. The default maximum line length is 72
134 characters. You may set these parameters by direct assignment to the
135 context structure once it has been initialized.
137 Decoding is performed similarly by the
139 function. The comments above about flushing output apply equally to
142 Decoding ignores all errors. In particular, whitespace is ignored, and
143 in the case of Base64 and Base32 encodings, it also ignores
145 characters in the string.
151 Mark Wooding, <mdw@distorted.org.uk>