base64 encoder decoder

base64 encoder and decoder More...

Detailed Description

encoding and decoding functions for base64

Author
Martin Landsmann Marti.nosp@m.n.La.nosp@m.ndsma.nosp@m.nn@H.nosp@m.AW-Ha.nosp@m.mbur.nosp@m.g.de

Macros

#define BASE64_SUCCESS   (0)
 return value for success
 
#define BASE64_ERROR_BUFFER_OUT   (-1)
 error value for invalid output buffer pointer
 
#define BASE64_ERROR_BUFFER_OUT_SIZE   (-2)
 error value for invalid output buffer size
 
#define BASE64_ERROR_DATA_IN   (-3)
 error value for invalid input buffer
 
#define BASE64_ERROR_DATA_IN_SIZE   (-4)
 error value for invalid input buffer size
 

Functions

int base64_encode (unsigned char *data_in, size_t data_in_size, unsigned char *base64_out, size_t *base64_out_size)
 Encodes a given datum to base64 and save the result to the given destination. More...
 
int base64_decode (unsigned char *base64_in, size_t base64_in_size, unsigned char *data_out, size_t *data_out_size)
 Decodes a given base64 string and save the result to the given destination. More...
 

Function Documentation

◆ base64_decode()

int base64_decode ( unsigned char *  base64_in,
size_t  base64_in_size,
unsigned char *  data_out,
size_t *  data_out_size 
)
Parameters
[out]base64_inpointer to store the encoded base64 string
[in]base64_in_sizepointer to the variable containing the size of base64_out.
[in]data_outpointer to the datum to encode
[in,out]data_out_sizethe size of data_out. This value is overwritten with the estimated size used for the decoded string on BASE64_ERROR_BUFFER_OUT_SIZE. This value is overwritten with the actual used size for the decoded string on BASE64_SUCCESS.
Returns
BASE64_SUCCESS on success, BASE64_ERROR_BUFFER_OUT_SIZE on insufficient size for decoding to data_out, BASE64_ERROR_BUFFER_OUT if data_out equals NULL but the size for data_out_size is sufficient, BASE64_ERROR_DATA_IN if base64_in equals NULL, BASE64_ERROR_DATA_IN_SIZE if base64_in_size is less then 4.

◆ base64_encode()

int base64_encode ( unsigned char *  data_in,
size_t  data_in_size,
unsigned char *  base64_out,
size_t *  base64_out_size 
)
Parameters
[in]data_inpointer to the datum to encode
[in]data_in_sizethe size of data_in
[out]base64_outpointer to store the encoded base64 string
[in,out]base64_out_sizepointer to the variable containing the size of base64_out. This value is overwritten with the estimated size used for the encoded base64 string on BASE64_ERROR_BUFFER_OUT_SIZE. This value is overwritten with the actual used size for the encoded base64 string on BASE64_SUCCESS.
Returns
BASE64_SUCCESS on success, BASE64_ERROR_BUFFER_OUT_SIZE on insufficient size for encoding to base64_out, BASE64_ERROR_BUFFER_OUT if base64_out equals NULL but the base64_out_size is sufficient, BASE64_ERROR_DATA_IN if data_in equals NULL, BASE64_ERROR_DATA_IN_SIZE if data_in_size is less then 1.