1 Base64 and Base224 encodings
2 ============================
4 These modules can be used to encode and decode data to and from
5 base64 (described in RFC 3548) and base224 (not described in any
6 standard, uses all non-control characters of ASCII).
11 - <<basecode,The basecode utility>>
27 - You may want to encode small block of known size. Just allocate the
28 output buffer and feed the data to the function.
30 byte output[BASE64_ENC_LENGTH(input_size)];
31 uns output_size = base64_encode(output, input, input_size);
33 - Decoding can be done in similar way. It is enough to have output
34 buffer of the same size as the input one.
36 - Encoding of a stream of unknown or large size can be split into
37 chunks. The input chunk size must be multiple of `BASE64_IN_CHUNK`.
38 The output will be corresponding multiple of `BASE64_OUT_CHUNK`.
41 byte input[BASE64_IN_CHUNK * 10];
42 while(input_size = read_chunk(input, BASE64_IN_CHUNK * 10)) {
43 byte output[BASE64_OUT_CHUNK * 10];
44 uns output_size = base64_encode(output, input, input_size);
45 use_chunk(output, output_size);
48 - Decoding of a stream is done in the same way, just swap
49 `BASE64_IN_CHUNK` and `BASE64_OUT_CHUNK` (you feed the decode
50 function with `BASE64_OUT_CHUNK` multiple and get `BASE64_IN_CHUNK`
53 The base224 has similar interface, therefore you can use it the same
59 You can use the encoding/decoding routines from command line, trough
60 `basecode` command. You have to specify the operation by a command
61 line argument and give it the data on standard input. The arguments
64 - `-e`: Encode to base64.
65 - `-d`: Decode from base64.
66 - `-E`: Encode to base224.
67 - `-D`: Decode from base224.
69 Furthermore, you can provide `--prefix` argument. If you do, the
70 output (when encoding) will be split to lines by default number of
71 chunks and the value of prefix will be prepended to each of them.
72 When decoding, it removes the prefix from the beginning of line.
74 You can override the default number of blocks for line-splitting by