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>"
23 .B " unsigned maxline;"
27 .ta \w'\fBvoid base64_encode('u
28 .BI "void base64_encode(base64_ctx *" ctx ,
29 .BI " const void *" p ", size_t " sz ,
31 .BI "void base64_decode(base64_ctx *" ctx ,
32 .BI " const void *" p ", size_t " sz ,
34 .BI "void base64_init(base64_ctx *" ctx );
39 .B " unsigned maxline;"
43 .ta \w'\fBvoid base32_encode('u
44 .BI "void base32_encode(base32_ctx *" ctx ,
45 .BI " const void *" p ", size_t " sz ,
47 .BI "void base32_decode(base32_ctx *" ctx ,
48 .BI " const void *" p ", size_t " sz ,
50 .BI "void base32_init(base32_ctx *" ctx );
55 .B " unsigned maxline;"
59 .ta \w'\fBvoid hex_encode('u
60 .BI "void hex_encode(hex_ctx *" ctx ,
61 .BI " const void *" p ", size_t " sz ,
63 .BI "void hex_decode(hex_ctx *" ctx ,
64 .BI " const void *" p ", size_t " sz ,
66 .BI "void hex_init(hex_ctx *" ctx );
74 functions perform encoding and decoding of arbitrary binary strings, as
75 defined by RFC4648, but without error reporting. These functions are
76 obsolete, and new applications should use the
78 interface, which provides more encoding and decoding options, and proper
81 The interfaces to these sets of functions is very similar: in
82 the following description,
90 Before encoding or decoding a string, a
94 must be initialized, by passing it to
96 The context contains data which must be retained between calls to encode
97 or decode substrings. The
99 function sets up initial values for the data, and sets up defaults for
100 the output formatting settings (see below).
102 Encoding of a string is performed by the
104 function. It is passed a pointer to a context block
106 the input substring to encode passed by address
110 and a pointer to a dynamic string
112 in which to write its output (see
114 for details on dynamic strings). Once all the input data has been
117 it is necessary to flush the final few bytes of output. This is
120 a null pointer as its source argument. It is an error to attempt to
121 continue encoding after flushing output.
125 function is formatted into lines using values from the context
128 member is a pointer to a null-terminated string which is used to
129 separate the output lines. The default indent string contains only a
130 newline character. The
132 member gives the maximum length of line that
134 is allowed to produce. If this is not a multiple of 4, it is rounded
135 up to the next highest multiple of four before use. A value of zero
138 not to perform line splitting: the output will be a single (possibly
139 very long) output line. The default maximum line length is 72
140 characters. You may set these parameters by direct assignment to the
141 context structure once it has been initialized.
143 Decoding is performed similarly by the
145 function. The comments above about flushing output apply equally to
148 Decoding ignores all errors. In particular, whitespace is ignored, and
149 in the case of Base64 and Base32 encodings, it also ignores
151 characters in the string.
157 Mark Wooding, <mdw@distorted.org.uk>