28 lines
666 B
C
28 lines
666 B
C
#ifndef __BASE64_H
|
|
#define __BASE64_H
|
|
|
|
#include <stdint.h>
|
|
|
|
/*
|
|
* Public API
|
|
*/
|
|
// Encode data as URL-safe Base64.
|
|
// Parameters:
|
|
// - data - data to encode
|
|
// - size - size of data to encode
|
|
// Returns:
|
|
// - pointer to resulting \0-terminated string (you must free() it)
|
|
// - NULL on out-of-memory
|
|
char *base64_encode(const void *data, uint32_t size);
|
|
|
|
// Decode data from URL-safe Base64.
|
|
// Parameters:
|
|
// - data - data to decode (must have \0)
|
|
// - out_size - size of decoded data
|
|
// Returns:
|
|
// - pointer to decoded data (you must free() it)
|
|
// - NULL on out-of-memory
|
|
void *base64_decode(const char *data, uint32_t *out_size);
|
|
|
|
#endif
|