]> mj.ucw.cz Git - moe.git/blob - ucw/base64.h
Merge commit '700824d3e9bce9219819e4e5096ab94da301d44b' from branch bernard/master
[moe.git] / ucw / base64.h
1 /*
2  *      UCW Library -- Base 64 Encoding & Decoding
3  *
4  *      (c) 2002, Robert Spalek <robert@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 /**
11  * Encodes @len bytes of data pointed to by @src by base64 encoding.
12  * Stores them in @dest and returns the number of bytes the output
13  * takes.
14  */
15 uns base64_encode(byte *dest, const byte *src, uns len);
16 /**
17  * Decodes @len bytes of data pointed to by @src from base64 encoding.
18  * All invalid characters are ignored. The result is stored into @dest
19  * and length of the result is returned.
20  */
21 uns base64_decode(byte *dest, const byte *src, uns len);
22
23 /**
24  * Use this macro to calculate @base64_encode() output buffer size.
25  */
26 #define BASE64_ENC_LENGTH(x) (((x)+2)/3 *4)
27
28 /*
29  * When called for BASE64_IN_CHUNK-byte chunks, the result will be
30  * always BASE64_OUT_CHUNK bytes long. If a longer block is split
31  * to such chunks, the result will be identical.
32  */
33 #define BASE64_IN_CHUNK 3 /** Size of chunk on the un-encoded side. **/
34 #define BASE64_OUT_CHUNK 4 /** Size of chunk on the encoded side. **/
35