Skip to content
Base64 encoder/decoder for arduino repo
C++
Branch: master
Clone or download
Your Name
Latest commit 5b8075c Oct 13, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fix parameter name in header Oct 13, 2018
.gitignore .gitignore catch test binary Feb 11, 2016
.travis.yml Travis CI setup Feb 11, 2016
LICENSE Initial commit Feb 10, 2016
Makefile Switch to header-only Jun 9, 2016
README.md Fix typo Feb 12, 2016
catch.cpp Switch to .*pp extensions Feb 11, 2016
catch.hpp Unit testing for encoding half Feb 11, 2016
library.properties Fix parameter name in header Oct 13, 2018

README.md

base64_arduino

Base64 encoder/decoder for arduino repo

npm Build Status

Installation

Add base64.cpp and base64.hpp to your project folder or library search path, put #include "base64.hpp" in your source, and pass base64.cpp to your compiler

Usage

unsigned char binary[] = {133, 244, 117, 206, 178, 195};
unsigned char base64[9];

unsigned int base64_length = encode_base64(binary, 6, base64);

printf("%d\n", base64_length); // Prints "8"
printf((char *) base64); // Prints "hfR1zrLD"
unsigned char base64[] = "hfR1zrLD";
unsigned char binary[6];

unsigned int binary_length = decode_base64(base64, binary);

printf("[%d, %d, %d, %d, %d, %d]\n", // Prints "[133, 244, 117, 206, 178, 195]"
       binary[0], binary[1], binary[2],
       binary[3], binary[4], binary[5]);
printf("%d\n", binary_length); // Prints "6"

Details

Uses common web conventions - '+' for 62, '/' for 63, '=' for padding. Note that invalid base64 characters are interpreted as padding.

Can be compiled as C, uses .*pp extensions because it is usually used in C++ projects and is tested for C++.

License

MIT

You can’t perform that action at this time.