Base64 encoding and decoding functions. More...
#include <sofia-sip/su_types.h>
Go to the source code of this file.
Defines | |
#define | BASE64_SIZE(n) |
Calculate size of n bytes encoded in base64. | |
#define | BASE64_MINSIZE(n) |
Calculate size of n bytes encoded in base64 sans trailing =. | |
Functions | |
isize_t | base64_d (char buf[], isize_t bsiz, char const *b64s) |
Decode a BASE64-encoded string. | |
isize_t | base64_e (char buf[], isize_t bsiz, void *data, isize_t dsiz) |
Encode data with BASE64. |
Base64 encoding and decoding functions.
This module contains base64 encoding and decoding functions. Base64 encodes arbitrary octet strings as strings containing characters [A-Za-z0-9+/=]. Base64 is defined as part of MIME mail format, but it is used widely by other text-based protocols as well.
#define BASE64_MINSIZE | ( | n | ) |
Calculate size of n bytes encoded in base64 sans trailing =.
Decode a BASE64-encoded string.
The function base64_d() decodes a string b64s encoded with BASE64. It stores the result in the buffer buf of bsiz bytes.
If the buf is NULL, the function just returns the length of decoded data. In any case, no decoded data is stored in buf beyond bsiz. The function always returns the full length of decodable data.
buf | Buffer to store decoded data | |
bsiz | Size of buf | |
b64s | Base64-encoded string. |
Encode data with BASE64.
The function base64_e() encodes dsiz bytes of data into buf.
If bsiz is zero, the function just returns the length of BASE64 encoding, excluding the final NUL
.
If encoded string is longer than that bsiz, the function terminates string with NUL
at buf[bsiz-1], but returns the length of encoding as usual.
buf | buffer for encoded data | |
bsiz | size of buffer | |
data | data to be encoded | |
dsiz | size of data |