#include <stddef.h>
Go to the source code of this file.
|
size_t | base64 (const char *signed_data, size_t len_data, char *res, size_t res_len) |
| Implementation of base64 algorithm for binaries in general. More...
|
|
size_t | base64_str (const char *s, char *res, size_t res_len) |
| Implementation of base64 algorithm for strings. More...
|
|
char * | open_and_read (const char *path, size_t *file_size_out) |
| Open and read files. More...
|
|
char * | base64_alloc (const char *data, size_t size, size_t *res_size_out) |
| Allocates memory and applies base64 algorithm. More...
|
|
char * | base64_from_path (const char *path, size_t *res_size_out) |
| Uses open_and_read() and base64_alloc() to perform base64 algorithm. More...
|
|
◆ base64()
size_t base64 |
( |
const char * |
signed_data, |
|
|
size_t |
len_data, |
|
|
char * |
res, |
|
|
size_t |
res_len |
|
) |
| |
Implementation of base64 algorithm for binaries in general.
Binary-to-text encoding into a set of 64 unique characters. Dource is taken 6 bits at a time, in this group of 6 is mapped to one of 64 unique characters. See: https://en.wikipedia.org/wiki/Base64
- Parameters
-
data | Pointer to the binary to encode. |
len_data | Length of binary to encode. |
res | Pointer to the result. |
res_len | Max-size of result. Needs to be enough. |
- Returns
- Size of final result. If > to res_len, you have you given enough space to res.
◆ base64_alloc()
char * base64_alloc |
( |
const char * |
data, |
|
|
size_t |
size, |
|
|
size_t * |
res_size_out |
|
) |
| |
Allocates memory and applies base64 algorithm.
- Parameters
-
data | Pointer to the binary to encode. |
size | Length of binary to encode. |
res_size_out | Pointer to the size of result. |
- Returns
- Pointer to the result. Does malloc()! So you should free later.
◆ base64_from_path()
char * base64_from_path |
( |
const char * |
path, |
|
|
size_t * |
res_size_out |
|
) |
| |
Uses open_and_read() and base64_alloc() to perform base64 algorithm.
- Parameters
-
path | Pointer to the binary to encode. |
res_size_out | Pointer to the size of result. |
- Returns
- Pointer to the result. Does malloc()! So you should free later.
◆ base64_str()
size_t base64_str |
( |
const char * |
s, |
|
|
char * |
res, |
|
|
size_t |
res_len |
|
) |
| |
Implementation of base64 algorithm for strings.
Just gets the data length by using strlen().
- Parameters
-
data | Pointer to the binary to encode. |
res | Pointer to the result. |
res_len | Max-size of result. Needs to be enough. |
- Returns
- Size of final result. If > to res_len, you have you given enough space to res.
◆ open_and_read()
char * open_and_read |
( |
const char * |
path, |
|
|
size_t * |
file_size_out |
|
) |
| |
Open and read files.
Deals with errors and allocates required size.
- Parameters
-
path | Pointer to the file name. |
file_size_out | Pointer to the size of result. |
- Returns
- Pointer to the result. Does malloc()! So you should free later.