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>"
20 .BI "void base64_encode(base64_ctx *" ctx ,
21 .BI " const void *" p ", size_t " sz ,
23 .BI "void base64_decode(base64_ctx *" ctx ,
24 .BI " const void *" p ", size_t " sz ,
26 .BI "void base64_init(base64_ctx *" ctx );
28 .BI "void base32_encode(base32_ctx *" ctx ,
29 .BI " const void *" p ", size_t " sz ,
31 .BI "void base32_decode(base32_ctx *" ctx ,
32 .BI " const void *" p ", size_t " sz ,
34 .BI "void base32_init(base32_ctx *" ctx );
36 .BI "void hex_encode(hex_ctx *" ctx ,
37 .BI " const void *" p ", size_t " sz ,
39 .BI "void hex_decode(hex_ctx *" ctx ,
40 .BI " const void *" p ", size_t " sz ,
42 .BI "void hex_init(hex_ctx *" ctx );
50 functions perform encoding and decoding of arbitrary binary strings, as
51 defined by RFC4648, but without error reporting. These functions are
52 obsolete, and new applications should use the
54 interface, which provides more encoding and decoding options, and proper
57 The interfaces to these sets of functions is very similar: in
58 the following description,
66 Before encoding or decoding a string, a
70 must be initialized, by passing it to
72 The context contains data which must be retained between calls to encode
73 or decode substrings. The
75 function sets up initial values for the data, and sets up defaults for
76 the output formatting settings (see below).
78 Encoding of a string is performed by the
80 function. It is passed a pointer to a context block
82 the input substring to encode passed by address
86 and a pointer to a dynamic string
88 in which to write its output (see
90 for details on dynamic strings). Once all the input data has been
93 it is necessary to flush the final few bytes of output. This is
96 a null pointer as its source argument. It is an error to attempt to
97 continue encoding after flushing output.
101 function is formatted into lines using values from the context
104 member is a pointer to a null-terminated string which is used to
105 separate the output lines. The default indent string contains only a
106 newline character. The
108 member gives the maximum length of line that
110 is allowed to produce. If this is not a multiple of 4, it is rounded
111 up to the next highest multiple of four before use. A value of zero
114 not to perform line splitting: the output will be a single (possibly
115 very long) output line. The default maximum line length is 72
116 characters. You may set these parameters by direct assignment to the
117 context structure once it has been initialized.
119 Decoding is performed similarly by the
121 function. The comments above about flushing output apply equally to
124 Decoding ignores all errors. In particular, whitespace is ignored, and
125 in the case of Base64 and Base32 encodings, it also ignores
127 characters in the string.
133 Mark Wooding, <mdw@distorted.org.uk>