foot/base64.h
Daniel Eklöf 4bc8a39d6c
base64: add base64_encode_oneshot()
Convenience function for base64_encode() + base64_encode_final().

Internally, we also add base64_encode_to_buffer()

This is an internal function that encodes a multiple-of-three long
input into a user allocated buffer.

base64_encode() and base64_encode_oneshot() uses the new function to
do the bulk of the encoding. This allows base64_encode_oneshot() to do
a single allocation.

This patch also adds unit tests for both base64_encode() and
base64_encode_oneshot() (but _not_ for base64_encode_final()).

Finally, the type of the 'data' parameter is changed to 'void*'.
2026-05-22 11:58:54 +02:00

9 lines
293 B
C

#pragma once
#include <stdint.h>
#include <stddef.h>
char *base64_decode(const char *s, size_t *out_len);
char *base64_encode(const void *data, size_t size);
void base64_encode_final(const void *data, size_t size, char result[4]);
char *base64_encode_oneshot(const void *data, size_t size);