Base64
[Algorithms]


Files

file  base64.c
 Base64 implementation.
file  base64.h
 Base64 header.

Functions

void base64_encode_block (unsigned char out[4], const unsigned char in[3], int len)
 Encode a minimal memory block.
int base64_decode_block (unsigned char out[3], const unsigned char in[4])
 Decode a minimal memory block.
size_t base64_encoded_size (size_t len)
 Compute size of needed storage for encoding.
size_t base64_decoded_size (size_t len)
 Compute size of needed storage for decoding.
void base64_encode_binary (char *out, const unsigned char *in, size_t len)
 Encode an arbitrary size memory area.
int base64_decode_binary (unsigned char *out, const char *in)
 Decode an arbitrary size memory area.
char * base64_encode (const char *in, size_t size)
 Encode a string.
char * base64_decode (const char *in)
 Decode a string.

Function Documentation

void base64_encode_block ( unsigned char  out[4],
const unsigned char  in[3],
int  len 
)

Encode a minimal memory block.

This function encodes a minimal memory area of three bytes into a printable base64-format sequence of four bytes. It is mainly used in more convenient functions, see below.

Attention:
This function can't check if there's enough space at the memory memory location pointed to by out, so be careful.
Parameters:
out pointer to destination
in pointer to source
len input size in bytes (between 0 and 3)
Returns:
nothing

Definition at line 105 of file base64.c.

References base64_list.

Referenced by base64_encode_binary().

int base64_decode_block ( unsigned char  out[3],
const unsigned char  in[4] 
)

Decode a minimal memory block.

This function decodes a minimal memory area of four bytes into its decoded equivalent. It is mainly used in more convenient functions, see below.

Attention:
This function can't check if there's enough space at the memory memory location pointed to by out, so be careful.
Parameters:
out pointer to destination
in pointer to source
Returns:
-1 on error (illegal character) or the number of bytes decoded

Definition at line 126 of file base64.c.

References base64_index, and XX.

Referenced by base64_decode_binary().

size_t base64_encoded_size ( size_t  len  ) 

Compute size of needed storage for encoding.

This function computes the exact size of a memory area needed to hold the result of an encoding operation, not including the terminating null character.

Parameters:
len input size
Returns:
output size

Definition at line 159 of file base64.c.

Referenced by base64_encode().

size_t base64_decoded_size ( size_t  len  ) 

Compute size of needed storage for decoding.

This function computes the estimated size of a memory area needed to hold the result of a decoding operation, not including the terminating null character. Note that this function may return up to two bytes more due to the nature of Base64.

Parameters:
len input size
Returns:
output size

Definition at line 174 of file base64.c.

Referenced by base64_decode().

void base64_encode_binary ( char *  out,
const unsigned char *  in,
size_t  len 
)

Encode an arbitrary size memory area.

This function encodes the first len bytes of the contents of the memory area pointed to by in and stores the result in the memory area pointed to by out. The result will be null-terminated.

Attention:
This function can't check if there's enough space at the memory memory location pointed to by out, so be careful.
Parameters:
out pointer to destination
in pointer to source
len input size in bytes
Returns:
nothing

Definition at line 194 of file base64.c.

References base64_encode_block().

Referenced by base64_encode().

int base64_decode_binary ( unsigned char *  out,
const char *  in 
)

Decode an arbitrary size memory area.

This function decodes the base64-string pointed to by in and stores the result in the memory area pointed to by out. The result will not be null-terminated.

Attention:
This function can't check if there's enough space at the memory memory location pointed to by out, so be careful.
Parameters:
out pointer to destination
in pointer to source
Returns:
-1 on error (illegal character) or the number of bytes decoded

Definition at line 225 of file base64.c.

References base64_decode_block().

Referenced by base64_decode().

char* base64_encode ( const char *  in,
size_t  size 
)

Encode a string.

This is a convenience function. It encodes the first size bytes of the string pointed to by in, stores the null-terminated result in a newly created memory area and returns a pointer to it.

Attention:
After a call to base64_encode(), you have to free() the result yourself.
Parameters:
in pointer to string
size strlen
Returns:
NULL on error (not enough memory) or a pointer to the encoded result

Definition at line 255 of file base64.c.

References base64_encode_binary(), and base64_encoded_size().

char* base64_decode ( const char *  in  ) 

Decode a string.

This is a convenience function. It decodes the null-terminated string pointed to by in, stores the result in a newly created memory area and returns a pointer to it. The result will be null-terminated.

Attention:
After a call to base64_decode(), you have to free() the result yourself.
Parameters:
in pointer to string
Returns:
NULL on error (not enough memory) or a pointer to the decoded result

Definition at line 289 of file base64.c.

References base64_decode_binary(), and base64_decoded_size().


Generated on Thu Jul 19 13:36:09 2007 for libv by  doxygen 1.5.1-p1. Thank you, SourceForge.net Logo