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, briefly described in
7 a comment at the beginning of `ucw/base224.c`).
12 - <<basecode,The basecode utility>>
28 - You may want to encode small block of known size. Just allocate the
29 output buffer and feed the data to the function.
31 byte output[BASE64_ENC_LENGTH(input_size)];
32 uns output_size = base64_encode(output, input, input_size);
34 - Decoding can be done in similar way. It is enough to have output
35 buffer of the same size as the input one.
37 - Encoding of a stream of unknown or large size can be split into
38 chunks. The input chunk size must be multiple of `BASE64_IN_CHUNK`.
39 The output will be corresponding multiple of `BASE64_OUT_CHUNK`.
42 byte input[BASE64_IN_CHUNK * 10];
43 while(input_size = read_chunk(input, BASE64_IN_CHUNK * 10)) {
44 byte output[BASE64_OUT_CHUNK * 10];
45 uns output_size = base64_encode(output, input, input_size);
46 use_chunk(output, output_size);
49 - Decoding of a stream is done in the same way, just swap
50 `BASE64_IN_CHUNK` and `BASE64_OUT_CHUNK` (you feed the decode
51 function with `BASE64_OUT_CHUNK` multiple and get `BASE64_IN_CHUNK`
54 The base224 has similar interface, therefore you can use it the same
60 You can use the encoding/decoding routines from command line, trough
61 `basecode` command. You have to specify the operation by a command
62 line argument and give it the data on standard input. The arguments
65 - `-e`: Encode to base64.
66 - `-d`: Decode from base64.
67 - `-E`: Encode to base224.
68 - `-D`: Decode from base224.
70 Furthermore, you can provide `--prefix` argument. If you do, the
71 output (when encoding) will be split to lines by default number of
72 chunks and the value of prefix will be prepended to each of them.
73 When decoding, it removes the prefix from the beginning of line.
75 You can override the default number of blocks for line-splitting by