DeterministicESPAsyncWebServer 1.2.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
base64.cpp File Reference

Base64 encoder/decoder implementation. More...

#include "base64.h"
#include "mbedtls/base64.h"
#include <string.h>

Go to the source code of this file.

Functions

void base64_encode (const uint8_t *src, size_t src_len, char *dst)
 Encode src_len bytes of src as Base64.
 
size_t base64_decode (const char *src, uint8_t *dst)
 Decode a null-terminated Base64 string.
 

Detailed Description

Base64 encoder/decoder implementation.

On Arduino (ESP32) targets, delegates to mbedtls_base64_encode/decode() which is part of the ESP-IDF mbedTLS bundle — same SDK path as SHA-1.

On native (x86) test targets, uses a portable software implementation so unit tests run without mbedTLS installed.

Definition in file base64.cpp.

Function Documentation

◆ base64_encode()

void base64_encode ( const uint8_t *  src,
size_t  src_len,
char *  dst 
)

Encode src_len bytes of src as Base64.

Writes a null-terminated string into dst. dst must be at least ((src_len + 2) / 3) * 4 + 1 bytes.

Parameters
srcInput bytes.
src_lenNumber of input bytes.
dstOutput buffer (null-terminated Base64 string).

Definition at line 23 of file base64.cpp.

◆ base64_decode()

size_t base64_decode ( const char *  src,
uint8_t *  dst 
)

Decode a null-terminated Base64 string.

Writes decoded bytes into dst. dst must be at least (strlen(src) / 4) * 3 bytes. Returns the number of decoded bytes. Returns 0 on invalid input.

Parameters
srcNull-terminated Base64 input string.
dstOutput byte buffer.
Returns
Number of bytes written to dst, or 0 on error.

Definition at line 31 of file base64.cpp.