Base64 conversion.
More...
|
int | util_base64_encode (const unsigned char *src, int slen, char *dst, int dlen) |
| Converts the bytestring src into the base64 string dst . More...
|
|
int | util_base64_decode (const char *src, int slen, unsigned char *dst, int dlen) |
| Decodes the string src from base64 into the bytestring dst . More...
|
|
int | util_base64_decode_verify (const char *src, int slen) |
| Verfies sanity of the base64 string src and calculates the size, a buffer would need for the decoded bytes. More...
|
|
int | util_base64_decode_unchecked (const char *src, int slen, unsigned char *dst, int dlen) |
| Decodes the string src from base64 into the bytestring dst . More...
|
|
Base64 conversion.
int util_base64_decode |
( |
const char * |
src, |
|
|
int |
slen, |
|
|
unsigned char * |
dst, |
|
|
int |
dlen |
|
) |
| |
Decodes the string src
from base64 into the bytestring dst
.
- Parameters
-
src | Base64 encoded string. May contain whitespaces. |
slen | length of the string src . |
dst | preallocated buffer to write bytestring to. |
dlen | size of the buffer dst in bytes. |
- Returns
- Returns the number of bytes written to
dst
. If dst
is NULL and dlen
is 0 the required size of the buffer will be returned. If dst
is to small for writing the complete base64 encoded string, the number of actually written bytes is returned. Returns -1 if src
is malformed.
int util_base64_decode_unchecked |
( |
const char * |
src, |
|
|
int |
slen, |
|
|
unsigned char * |
dst, |
|
|
int |
dlen |
|
) |
| |
Decodes the string src
from base64 into the bytestring dst
.
Does not check sanity of src
before decoding.
- Parameters
-
src | Base64 encoded string. May contain whitespaces. |
slen | length of the string src . |
dst | preallocated buffer to write bytestring to. |
dlen | size of the buffer dst in bytes. |
- Returns
- Returns the number of bytes written to
dst
. If dst
is too small for writing the complete base64 encoded string, the number of actually written bytes is returned. If decoding fails -1 is returned.
int util_base64_decode_verify |
( |
const char * |
src, |
|
|
int |
slen |
|
) |
| |
Verfies sanity of the base64 string src
and calculates the size, a buffer would need for the decoded bytes.
- Parameters
-
src | Base64 encoded string |
slen | Lenght of src |
- Returns
- Returns -1 if the string is malformed. On success the number of bytes a buffer would need to hold the completely decoded string are returned.
int util_base64_encode |
( |
const unsigned char * |
src, |
|
|
int |
slen, |
|
|
char * |
dst, |
|
|
int |
dlen |
|
) |
| |
Converts the bytestring src
into the base64 string dst
.
- Parameters
-
src | byte array to encode to base64. |
slen | length of src in bytes. |
dst | preallocated buffer to write base64 string to. |
dlen | size of dst buffer in bytes. This function writes at most dlen-1 characters to dst and always adds a null byte. |
- Returns
- Returns the number of bytes that have been written or would be written (excluding the terminating null byte) to
dst
. If dst
is too small for writing the complete base64 encoded string, a truncated but still valid base64 string will be written. If dst
is NULL and dlen
is 0 the size of the buffer dst
(excluding the terminating null byte) that is required to write the complete base64 string will be returned.