base64.cc File Reference

Functions to handle Base64 encoding and decoding. More...

#include <jabberdlib.h>

Functions

int base64_encode (unsigned char *source, size_t sourcelen, char *target, size_t targetlen)
void str_b64decode (char *str)
size_t base64_decode (const char *source, unsigned char *target, size_t targetlen)

Variables

const char * BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

Detailed Description

Functions to handle Base64 encoding and decoding.

The function to decode base64 data is base64_decode(), the general encoding function is base64_encode(). If the data that should get encoded is not binary data, but zero terminated character data, the str_b64decode() function can be used instead, which does not require the caller to specify the length of that data that should get encoded.


Function Documentation

size_t base64_decode ( const char *  source,
unsigned char *  target,
size_t  targetlen 
)

decode base64 encoded data

Parameters:
source the encoded data (zero terminated)
target pointer to the target buffer
targetlen length of the target buffer
Returns:
length of converted data on success, -1 otherwise

Referenced by dialback_in_read_db(), and str_b64decode().

int base64_encode ( unsigned char *  source,
size_t  sourcelen,
char *  target,
size_t  targetlen 
)

encode an array of bytes using Base64 (RFC 3548)

Parameters:
source the source buffer
sourcelen the length of the source buffer
target the target buffer
targetlen the length of the target buffer
Returns:
1 on success, 0 otherwise

Referenced by dialback_out_read().

void str_b64decode ( char *  str  ) 

decode a base64 string and put the result in the same buffer as the source

This function does not handle decoded data that contains the null byte very well as the size of the decoded data is not returned.

The result will be zero terminated.

Deprecated:
use base64_decode instead
Parameters:
str buffer for the source and the result

References base64_decode().


Variable Documentation

const char* BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

characters used for Base64 encoding


Generated on Thu Mar 11 06:00:05 2010 for jabberd14 by  doxygen 1.6.1