l8w8jwt
|
Base-64 encode and decode strings/bytes. More...
Go to the source code of this file.
Functions | |
L8W8JWT_API int | l8w8jwt_base64_encode (int url, const uint8_t *data, size_t data_length, char **out, size_t *out_length) |
L8W8JWT_API int | l8w8jwt_base64_decode (int url, const char *data, size_t data_length, uint8_t **out, size_t *out_length) |
Base-64 encode and decode strings/bytes.
Pass true
as first parameter if you want to use base64url encoding instead of base64.
L8W8JWT_API int l8w8jwt_base64_decode | ( | int | url, |
const char * | data, | ||
size_t | data_length, | ||
uint8_t ** | out, | ||
size_t * | out_length | ||
) |
Decodes a base-64 encoded string to an array of bytes.
out_length
. url | Decode using base64url instead of base64? Set to 0 for false ; anything else for true . |
data | The base-64 encoded string to decode (obtained via l8w8jwt_base64_encode ). |
data_length | The length of the string to decode. |
out | Output where the decoded bytes should be written into (will be malloc'ed, so make sure to free() this as soon as you're done using it!). |
out_length | Pointer to a size_t variable into which to write the output buffer's length. |
L8W8JWT_API int l8w8jwt_base64_encode | ( | int | url, |
const uint8_t * | data, | ||
size_t | data_length, | ||
char ** | out, | ||
size_t * | out_length | ||
) |
Encodes a byte array to a base-64 string.
If you're encoding a string, don't include the NUL terminator (pass strlen(data)
instead of the array's size to the data_length
parameter).
out_length
. url | base64url encode instead of base64? Set to 0 for false ; anything else for true . |
data | The data (array of bytes) to base-64 encode. |
data_length | The length of the input data array (in case of a C string: array size - 1 in order to omit the NUL terminator). |
out | Output where the base-64 encoded string should be written into (will be malloc'ed, so make sure to free() this as soon as you're done using it!). |
out_length | Pointer to a size_t variable containing the length of the output buffer minus the NUL terminator. |