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. |
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.
out
, so be careful.out | pointer to destination | |
in | pointer to source | |
len | input size in bytes (between 0 and 3) |
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.
out
, so be careful.out | pointer to destination | |
in | pointer to source |
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.
len | input 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.
len | input 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.
out
, so be careful.out | pointer to destination | |
in | pointer to source | |
len | input size in bytes |
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.
out
, so be careful.out | pointer to destination | |
in | pointer to source |
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.
in | pointer to string | |
size | strlen |
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.
in | pointer to string |
Definition at line 289 of file base64.c.
References base64_decode_binary(), and base64_decoded_size().