|  |  |  | GNet Network Library Reference Manual |  | 
|---|---|---|---|---|
#include <gnet.h> gchar* gnet_base64_encode (const gchar *src, gint srclen, gint *dstlenp, gboolean strict); gchar* gnet_base64_decode (const gchar *src, gint srclen, gint *dstlenp);
gchar* binary_stream = "Hello World!"; gchar* base64_stream; gint base64_len; gchar* newbin_stream; gint newbin_len; base64_stream = gnet_base64_encode(binary_stream,strlen(binary_stream), &base64_len, FALSE); newbin_stream = gnet_base64_decode(base64_stream, base64_len, &newbin_len);
This module provides functions to encode and decode strings into the Base64 encoding specified in "RFC 2045 - MIME (Multipurpose Internet Mail Extensions)". The Base64 encoding is designed to represent arbitrary sequences of octets in a form that need not be humanly readable. A 65-character subset ([A-Za-z0-9+/=]) of US-ASCII is used, enabling 6 bits to be represented per printable character.
gchar*              gnet_base64_encode                  (const gchar *src,
                                                         gint srclen,
                                                         gint *dstlenp,
                                                         gboolean strict);
Convert a buffer from binary to base64 representation.  Set
 strict to TRUE to insert a newline every 72th character.  This is
 required by RFC 2045, but some applications don't require this.
 If srclen is 0, an empty string will be returned (not NULL).
| src: | source buffer | 
| srclen: | length of the source buffer | 
| dstlenp: | length of the buffer returned (including the terminating \0) | 
| strict: | insert new lines as required by RFC 2045 | 
| Returns : | a newly-allocated and NUL-terminated string containing the
 input data in base64 coding. Free with g_free()when no longer needed. | 
gchar*              gnet_base64_decode                  (const gchar *src,
                                                         gint srclen,
                                                         gint *dstlenp);
Convert a buffer from base64 to binary representation. This function is liberal in what it will accept. It ignores non-base64 symbols.
| src: | the source buffer | 
| srclen: | the length of the source buffer, or -1 for strlen( src). | 
| dstlenp: | where to return the length of the returned output buffer | 
| Returns : | newly-allocated buffer. Free with g_free()when no longer
 needed. The integer pointed to bydstlenpis set to the length of
 that buffer. |