|
Base64pp
A simple, correct Base64 encoder written in modern C++
|
Base64pp is a C++ library that provides an efficient and easy-to-use interface, for encoding and decoding data in Base64 format. The library is lightweight and designed to be portable, making it an ideal choice for applications that need to support multiple platforms.
If you want to find out more about this implementation, check out the blog post about writing a Base64 encoder in C++
std::span<std::uint8_t>, meaning you can encode any blob of data.conan & vcpkg).Here's an example of using the base64pp library for a round-trip encoding of a file given as an argument.
Currently, you can use this library in a few different ways. Although limited, I am working on making base64pp easily accessible through package managers.
Build the project (seebuild section), and make sure you link against base64pp, while also copying the header base64pp/include/base64pp to your build system.
As of now, you can either include this project into your CMakeLists.txt via FetchContent{Declare,MakeAvailable}, via submodule, or copying the directory base64pp into your own project.
However, if you are including the project with submodule or copying the base64pp directory, make sure to call add_subdirectory(path-to/base4pp) in your CMakeLists.txt.
The plan is to make this library available through package managers.
Currently, I'm working on getting a working conan package for this repo. If you feel like you could help, feel free to create a fork and a PR!
This project can be build with CMake. Make sure you have a recent enough version of CMake (>= 3.21).
In addition, we build with the C++20 standard, so make sure your compiler supports this version.
Base64pp doesn't rely on any third-party libraries per se, but the unit tests were implemented with GTest. However, the dependencies were managed with Conan so you do need to install that first.
You can use the following script to install conan dependencies:
Run the build bash script provided in the repo. This assumes you have installed conan dependencies.
On Linux, call:
On Powershell (Windows), you can call:
Note that unix-rel and vs2022-rel are presets provided in the CMakePresets.json. Take a look at the build scripts for more info.
All the build files will be compiled to build/<PRESET-NAME>/base64pp.
Base64pp is licensed under the MIT license. See the LICENSE file for more details.
Contributions to base64pp are welcome. To contribute, please fork the repository, make your changes, and submit a pull request. Please ensure that your code follows the existing coding style and conventions, and include appropriate tests where necessary.