Skip to content

Instantly share code, notes, and snippets.

@noahcoad
Last active Jul 5, 2020
Embed
What would you like to do?
// base64 encoding and decoding example on ESP32 Arudino
// using the built-in libb64 libraries
//
// ~/Documents/Arduino/hardware/espressif/esp32/cores/esp32/libb64/cdecode.h
// ~/Documents/Arduino/hardware/espressif/esp32/cores/esp32/libb64/cencode.h
#include "libb64/cdecode.h"
#include "libb64/cencode.h"
void setup() {
const char* msg = "Hello World";
// encode
char encstr[base64_encode_expected_len(strlen(msg))];
int enclen = base64_encode_chars(msg, strlen(msg), encstr);
printf("Encoded: %s\n", encstr);
// decode
char decstr[base64_decode_expected_len(strlen(encstr))];
int declen = base64_decode_chars(encstr, strlen(encstr), decstr);
printf("Decoded: %s\n", decstr);
}
void loop() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment