Skip to content

Instantly share code, notes, and snippets.

Last active July 5, 2020 19:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save noahcoad/cb30cbaa63c21ab64a307ff7b73d0449 to your computer and use it in GitHub Desktop.
// 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