Module base64 [Version: ]
[Main Page] [Details] [Tests]
This documentation describes the Prokee module interface.
Static Methods:
encode
These methods can be used, if the input for the encoder is a null-terminated string.
The following methods returns a new allocated buffer, in which the output is written.
The following methods write the encoded data into an existing buffer.
encode (version 2)
int base64::encode(void *data,unsigned int length,char *bstr,bool padding)
encode (version 3)
int base64::encode(void *data,unsigned int length,char *bstr,bool padding,const char *sym,char pad)
These versions, perform a length check on the output buffer.
encode (version _s2)
int base64::encode(void *data,unsigned int length,char *bstr,unsigned int bln,bool padding)
encode (version _s3)
int base64::encode(void *data,unsigned int length,char *bstr,unsigned int bln,bool padding,const char *sym,char pad)
These versions reallocate the memory of the output buffer if necessary
encode (version _realloc3)
int base64::encode(void *data,unsigned int length,char **bstr,unsigned int *bln,bool padding,const char *sym,char pad)
encode_url
These versions use different encoding symbols to encode data in urls.
encode_url (version 3)
int base64::encode_url(void *data,unsigned int length,char *bstr,unsigned int bln,bool padding)
encode_url (version 4)
int base64::encode_url(void *data,unsigned int length,char **bstr,unsigned int *bln,bool padding)
encode_length
Calculates the lenght of the encoded base64 string.
decode_length
Calculates the length of the decoded data.
allocating a new buffer
decode
writing to existing buffer
writing to existing buffer with length check
decode (version _s2)
int base64::decode(char *bstr,void *data,unsigned int dataln,const char *sym,char pad)
reallocating version
decode_url
These versions are for url decoding
Static Methods
encode (version _str1)
Returns the base64 encoded representation of the input string
in_str.
Signature:
char *base64::encode(const char *in_str)
Parameters:| const char * | in_str | [IN] | a null-terminated string used as input for the encoder. |
Return value:The base64 encoded representation of the input string
in_str.
Remarks:
Die Funktion erzeugt einen base64 String mit allfälligem Padding. Als Padding Zeichen wird '=' verwenet.

Als Alphabet für die Codierung wird 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' verwendet.

The application has to free the returned buffer.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_str1()
encode (version _str2)
Returns the base64 encoded representation of the input string
in_str.
Signature:
char *base64::encode(const char *in_str,bool padding)
Parameters:| const char * | in_str | [IN] | a null-terminated string used as input for the encoder. |
| bool | padding | | wheter if padding schould be used or not. |
Return value:The base64 encoded representation of the input string
in_str.
Remarks:
Falls
padding auf
true gesetzt wurde, erzeugt die Funktion einen base64 String mit allfälligem Padding. Anderenfalls wird kein Padding erzeugt. Als Padding Zeichen wird '=' verwenet.

Als Alphabet für die Codierung wird 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' verwendet.

The application has to free the returned buffer.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_str2()
encode (version _str3)
Returns the base64 encoded representation of the input string
in_str.
Signature:
char *base64::encode(const char *in_str,bool padding,const char *sym,char pad)
Parameters:| const char * | in_str | [IN] | a null-terminated string used as input for the encoder. |
| bool | padding | | wheter if padding schould be used or not. |
| const char * | sym | [IN] | a null-terminated array holding the symbols to be used for encoding. For standard base64 encoding, sym should be set to "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/". The array can be given as null-terminated string constant. Mind that the array has to contain exactly 64 characters. The function will fail, otherwise. All characters need to be different. |
| char | pad | | the padding character. For standard base64 encoding, pad should be set to '='. |
Return value:The base64 encoded representation of the input string
in_str.
Remarks:
The application has to free the returned buffer.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_str3()
encode (version _wcs1)
Returns the base64 encoded representation of the input string
in_str.
Signature:
char *base64::encode(const wchar_t *in_str)
Parameters:| const wchar_t * | in_str | [IN] | a null-terminated string used as input for the encoder. |
Return value:The base64 encoded representation of the input string
in_str.
Remarks:
Die Funktion erzeugt einen base64 String mit allfälligem Padding. Als Padding Zeichen wird '=' verwenet.

Als Alphabet für die Codierung wird 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' verwendet.

The application has to free the returned buffer.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_wcs1()
encode (version _wcs2)
Returns the base64 encoded representation of the input string
in_str.
Signature:
char *base64::encode(const wchar_t *in_str,bool padding)
Parameters:| const wchar_t * | in_str | [IN] | a null-terminated string used as input for the encoder. |
| bool | padding | | wheter if padding schould be used or not. |
Return value:The base64 encoded representation of the input string
in_str.
Remarks:
Falls
padding auf
true gesetzt wurde, erzeugt die Funktion einen base64 String mit allfälligem Padding. Anderenfalls wird kein Padding erzeugt. Als Padding Zeichen wird '=' verwenet.

Als Alphabet für die Codierung wird 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' verwendet.

The application has to free the returned buffer.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_wcs2()
encode (version _wcs3)
Returns the base64 encoded representation of the input string
in_str.
Signature:
char *base64::encode(const wchar_t *in_str,bool padding,const char *sym,char pad)
Parameters:| const wchar_t * | in_str | [IN] | a null-terminated string used as input for the encoder. |
| bool | padding | | wheter if padding schould be used or not. |
| const char * | sym | [IN] | a null-terminated array holding the symbols to be used for encoding. For standard base64 encoding, sym should be set to "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/". The array can be given as null-terminated string constant. Mind that the array has to contain exactly 64 characters. The function will fail, otherwise. All characters need to be different. |
| char | pad | | the padding character. For standard base64 encoding, pad should be set to '='. |
Return value:The base64 encoded representation of the input string
in_str.
Remarks:
The application has to free the returned buffer.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_wcs3()
encode (version _alloc1)
Encodes the input from buffer
data and returns it as base64 encoded string.
Signature:
char *base64::encode(void *data,unsigned int length)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
Remarks:
The application has to free the returned buffer.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_alloc1()
encode (version _alloc2)
Encodes the input from buffer
data and returns it as base64 encoded string.
Signature:
char *base64::encode(void *data,unsigned int length,bool padding)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| bool | padding | | wheter if padding schould be used or not. |
Remarks:
The application has to free the returned buffer.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_alloc2()
encode (version _alloc3)
Encodes the input from buffer
data and returns it as base64 encoded string.
Signature:
char *base64::encode(void *data,unsigned int length,bool padding,const char *sym,char pad)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| bool | padding | | wheter if padding schould be used or not. |
| const char * | sym | [IN] | a null-terminated array holding the symbols to be used for encoding. For standard base64 encoding, sym should be set to "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/". The array can be given as null-terminated string constant. Mind that the array has to contain exactly 64 characters. The function will fail, otherwise. All characters need to be different. |
| char | pad | | the padding character. For standard base64 encoding, pad should be set to '='. |
Remarks:
The application has to free the returned buffer.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_alloc3()
encode (version 1)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode(void *data,unsigned int length,char *bstr)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char * | bstr | [OUT] | Receives the base64 encoded string. |
Return value:Returns 0 on successful execution.
Remarks:
Mind that
bstr has to be an already allocated buffer of sufficient size.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode1()
encode (version 2)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode(void *data,unsigned int length,char *bstr,bool padding)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char * | bstr | [OUT] | Receives the base64 encoded string. |
| bool | padding | | wheter if padding schould be used or not. |
Return value:Returns 0 on successful execution.
Remarks:
Mind that
bstr has to be an already allocated buffer of sufficient size.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode2()
encode (version 3)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode(void *data,unsigned int length,char *bstr,bool padding,const char *sym,char pad)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char * | bstr | [OUT] | Receives the base64 encoded string. |
| bool | padding | | wheter if padding schould be used or not. |
| const char * | sym | [IN] | a null-terminated array holding the symbols to be used for encoding. For standard base64 encoding, sym should be set to "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/". The array can be given as null-terminated string constant. Mind that the array has to contain exactly 64 characters. The function will fail, otherwise. All characters need to be different. |
| char | pad | | the padding character. For standard base64 encoding, pad should be set to '='. |
Return value:Returns 0 on successful execution.
Remarks:
Mind that
bstr has to be an already allocated buffer of sufficient size.
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode3()
encode (version _s1)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode(void *data,unsigned int length,char *bstr,unsigned int bln)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char * | bstr | [OUT] | Receives the base64 encoded string. |
| unsigned int | bln | | Length of buffer bstr |
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_s1()
encode (version _s2)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode(void *data,unsigned int length,char *bstr,unsigned int bln,bool padding)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char * | bstr | [OUT] | Receives the base64 encoded string. |
| unsigned int | bln | | Length of buffer bstr |
| bool | padding | | wheter if padding schould be used or not. |
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_s2()
encode (version _s3)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode(void *data,unsigned int length,char *bstr,unsigned int bln,bool padding,const char *sym,char pad)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char * | bstr | [OUT] | Receives the base64 encoded string. |
| unsigned int | bln | | Length of buffer bstr |
| bool | padding | | wheter if padding schould be used or not. |
| const char * | sym | [IN] | a null-terminated array holding the symbols to be used for encoding. For standard base64 encoding, sym should be set to "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/". The array can be given as null-terminated string constant. Mind that the array has to contain exactly 64 characters. The function will fail, otherwise. All characters need to be different. |
| char | pad | | the padding character. For standard base64 encoding, pad should be set to '='. |
Tests:
test1: Encode/Decode-Test.
Test function:
base64_encode_s3()
encode (version _realloc1)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode(void *data,unsigned int length,char **bstr,unsigned int *bln)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char ** | bstr | [OUT] | Receives the base64 encoded string. |
| unsigned int * | bln | [IN/OUT] | Length of buffer bstr |
encode (version _realloc2)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode(void *data,unsigned int length,char **bstr,unsigned int *bln,bool padding)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char ** | bstr | [OUT] | Receives the base64 encoded string. |
| unsigned int * | bln | [IN/OUT] | Length of buffer bstr |
| bool | padding | | wheter if padding schould be used or not. |
encode (version _realloc3)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode(void *data,unsigned int length,char **bstr,unsigned int *bln,bool padding,const char *sym,char pad)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char ** | bstr | [OUT] | Receives the base64 encoded string. |
| unsigned int * | bln | [IN/OUT] | Length of buffer bstr |
| bool | padding | | wheter if padding schould be used or not. |
| const char * | sym | [IN] | a null-terminated array holding the symbols to be used for encoding. For standard base64 encoding, sym should be set to "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/". The array can be given as null-terminated string constant. Mind that the array has to contain exactly 64 characters. The function will fail, otherwise. All characters need to be different. |
| char | pad | | the padding character. For standard base64 encoding, pad should be set to '='. |
encode_url (version 1)
Encodes the input from buffer
data and returns it as base64 encoded string.
Signature:
char *base64::encode_url(void *data,unsigned int length,bool padding)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| bool | padding | | wheter if padding schould be used or not. |
Remarks:
The application has to free the returned buffer.
encode_url (version 2)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode_url(void *data,unsigned int length,char *bstr,bool padding)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char * | bstr | [OUT] | Receives the base64 encoded string. |
| bool | padding | | wheter if padding schould be used or not. |
encode_url (version 3)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode_url(void *data,unsigned int length,char *bstr,unsigned int bln,bool padding)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char * | bstr | [OUT] | Receives the base64 encoded string. |
| unsigned int | bln | | Length of buffer bstr |
| bool | padding | | wheter if padding schould be used or not. |
encode_url (version 4)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::encode_url(void *data,unsigned int length,char **bstr,unsigned int *bln,bool padding)
Parameters:| void * | data | [IN] | The data to be encoded. |
| unsigned int | length | | The length in bytes of the data to be encoded. This mus not be 0. |
| char ** | bstr | [OUT] | Receives the base64 encoded string. |
| unsigned int * | bln | [IN/OUT] | Length of buffer bstr |
| bool | padding | | wheter if padding schould be used or not. |
encode_length (version 1)
This function calculates the length (in bytes) of the encoded string.
Signature:
unsigned int base64::encode_length(unsigned int length)
Parameters:| unsigned int | length | | The length in bytes of the data to be encoded. |
Return value:The length in bytes of the base64 encoded string.
encode_length (version 2)
This function calculates the length (in bytes) of the encoded string.
Signature:
unsigned int base64::encode_length(unsigned int length,bool padding)
Parameters:| unsigned int | length | | The length in bytes of the data to be encoded. |
| bool | padding | | wheter if padding schould be used or not. |
Return value:The length in bytes of the base64 encoded string.
decode_length (version 1)
This function calculates the length (in bytes) of the decoded string.
Signature:
unsigned int base64::decode_length(unsigned int length)
Parameters:| unsigned int | length | | The length in bytes of the base64 string to be decoded. |
Return value:The length in bytes of the decoded data.
decode_length (version 2)
This function calculates the length (in bytes) of the decoded string.
Signature:
unsigned int base64::decode_length(char *bstr)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
Return value:The length in bytes of the decoded data.
decode (version _alloc1)
Decodes the input from buffer
bstr and returns the decoded data.
Signature:
void *base64::decode(char *bstr)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
Remarks:
The application has to free the returned buffer.
decode (version _alloc2)
Decodes the input from buffer
bstr and returns the decoded data.
Signature:
void *base64::decode(char *bstr,const char *sym,char pad)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
| const char * | sym | [IN] | a null-terminated array holding the symbols to be used for encoding. For standard base64 encoding, sym should be set to "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/". The array can be given as null-terminated string constant. Mind that the array has to contain exactly 64 characters. The function will fail, otherwise. All characters need to be different. |
| char | pad | | the padding character. For standard base64 encoding, pad should be set to '='. |
Remarks:
The application has to free the returned buffer.
decode (version 1)
Decodes the input from buffer
bstr and writes the output to the existing buffer
data.
Signature:
int base64::decode(char *bstr,void *data)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
| void * | data | [OUT] | Receives the decoded data. |
Remarks:
Mind that the buffer
data has to be already allocated and of sufficient size.
decode (version 2)
Decodes the input from buffer
bstr and writes the output to the existing buffer
data.
Signature:
int base64::decode(char *bstr,void *data,const char *sym,char pad)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
| void * | data | [OUT] | Receives the decoded data. |
| const char * | sym | [IN] | a null-terminated array holding the symbols to be used for encoding. For standard base64 encoding, sym should be set to "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/". The array can be given as null-terminated string constant. Mind that the array has to contain exactly 64 characters. The function will fail, otherwise. All characters need to be different. |
| char | pad | | the padding character. For standard base64 encoding, pad should be set to '='. |
Remarks:
Mind that the buffer
data has to be already allocated and of sufficient size.
decode (version _s1)
Decodes the input from buffer
bstr and writes the output to the existing buffer
data.
Signature:
int base64::decode(char *bstr,void *data,unsigned int dataln)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
| void * | data | [OUT] | Receives the decoded data. |
| unsigned int | dataln | | The length of the buffer data. |
decode (version _s2)
Decodes the input from buffer
bstr and writes the output to the existing buffer
data.
Signature:
int base64::decode(char *bstr,void *data,unsigned int dataln,const char *sym,char pad)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
| void * | data | [OUT] | Receives the decoded data. |
| unsigned int | dataln | | The length of the buffer data. |
| const char * | sym | [IN] | a null-terminated array holding the symbols to be used for encoding. For standard base64 encoding, sym should be set to "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/". The array can be given as null-terminated string constant. Mind that the array has to contain exactly 64 characters. The function will fail, otherwise. All characters need to be different. |
| char | pad | | the padding character. For standard base64 encoding, pad should be set to '='. |
decode (version _realloc1)
Decodes the input from buffer
bstr and writes the output to the existing buffer
data.
Signature:
int base64::decode(char *bstr,void **data,unsigned int *dataln)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
| void ** | data | [OUT] | Receives the decoded data. |
| unsigned int * | dataln | [IN/OUT] | The length of the buffer data. |
decode (version _realloc2)
Decodes the input from buffer
bstr and writes the output to the existing buffer
data.
Signature:
int base64::decode(char *bstr,void **data,unsigned int *dataln,const char *sym,char pad)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
| void ** | data | [OUT] | Receives the decoded data. |
| unsigned int * | dataln | [IN/OUT] | The length of the buffer data. |
| const char * | sym | [IN] | a null-terminated array holding the symbols to be used for encoding. For standard base64 encoding, sym should be set to "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/". The array can be given as null-terminated string constant. Mind that the array has to contain exactly 64 characters. The function will fail, otherwise. All characters need to be different. |
| char | pad | | the padding character. For standard base64 encoding, pad should be set to '='. |
decode_url (version 2)
Decodes the input from buffer
bstr and writes the output to the existing buffer
data.
Signature:
void *base64::decode_url(char *bstr)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
Remarks:
The application has to free the returned buffer.
decode_url (version 1)
Decodes the input from buffer
bstr and writes the output to the existing buffer
data.
Signature:
int base64::decode_url(char *bstr,void *data)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
| void * | data | [OUT] | Receives the decoded data. |
Remarks:
Mind that the buffer
data has to be already allocated and of sufficient size.
decode_url (version 3)
Encodes the input from buffer
data and writes the output to the existing buffer
bstr.
Signature:
int base64::decode_url(char *bstr,void *data,unsigned int dataln)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
| void * | data | [OUT] | Receives the decoded data. |
| unsigned int | dataln | | The length of the buffer data. |
decode_url (version 4)
Decodes the input from buffer
bstr and writes the output to the existing buffer
data.
Signature:
int base64::decode_url(char *bstr,void **data,unsigned int *dataln)
Parameters:| char * | bstr | [IN] | The base64 encoded string. |
| void ** | data | [OUT] | Receives the decoded data. |
| unsigned int * | dataln | [IN/OUT] | The length of the buffer data. |