{"id":15136969,"url":"https://github.com/matheusgomes28/base64pp","last_synced_at":"2025-06-10T21:34:09.946Z","repository":{"id":71666754,"uuid":"429940993","full_name":"matheusgomes28/base64pp","owner":"matheusgomes28","description":"A modern C++ implementation of Base64 encoding and decoding.","archived":false,"fork":false,"pushed_at":"2024-10-22T19:19:34.000Z","size":353,"stargazers_count":27,"open_issues_count":10,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-30T18:38:09.297Z","etag":null,"topics":["base64","cmake","conan","cpp","library","modern-cpp","pkg","pkg-config","shared-library","static-library"],"latest_commit_sha":null,"homepage":"https://matgomes.com","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matheusgomes28.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-19T21:39:02.000Z","updated_at":"2024-12-12T21:32:32.000Z","dependencies_parsed_at":"2024-09-21T11:01:45.551Z","dependency_job_id":"c2e61046-25b1-49ae-8f26-fa25f1cdb093","html_url":"https://github.com/matheusgomes28/base64pp","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matheusgomes28%2Fbase64pp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matheusgomes28%2Fbase64pp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matheusgomes28%2Fbase64pp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matheusgomes28%2Fbase64pp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matheusgomes28","download_url":"https://codeload.github.com/matheusgomes28/base64pp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237821690,"owners_count":19371809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base64","cmake","conan","cpp","library","modern-cpp","pkg","pkg-config","shared-library","static-library"],"created_at":"2024-09-26T06:42:18.080Z","updated_at":"2025-02-08T14:31:21.577Z","avatar_url":"https://github.com/matheusgomes28.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://dev.azure.com/Matheusgarcia28/Base64pp/_apis/build/status%2Fmatheusgomes28.base64pp?branchName=main)](https://dev.azure.com/Matheusgarcia28/Base64pp/_build/latest?definitionId=3\u0026branchName=main) [![codecov](https://codecov.io/github/matheusgomes28/base64pp/branch/main/graph/badge.svg?token=5Q5G5MNFLO)](https://codecov.io/github/matheusgomes28/base64pp)\n\n# Base64pp - A Modern \u0026 Safe C++ Encoder\n\nBase64pp is a C++ library that provides an efficient and easy-to-use interface,\nfor encoding and decoding data in Base64 format. The library is lightweight\nand designed to be portable, making it an ideal choice for applications that\nneed to support multiple platforms.\n\nIf you want to find out more about this implementation, check out the blog post\nabout [writing a Base64 encoder in C++](https://matgomes.com/base64-encode-decode-cpp/)\n\n- [Features](#features-and-goals)\n- [Example Usage](#usage)\n- [Installation](#installation)\n- [Building](#building-the-project)\n- [License](#license)\n- [Contributing](#contributions)\n\n## Features And Goals\n- [x] A safe implementation of Base64 Encoding \u0026 Decoding.\n- [x] Tested with many edge test cases, unlike most Base64 snippets out there.\n- [x] Supports `std::span\u003cstd::uint8_t\u003e`, meaning you can encode any blob of data.\n- [x] High testing coverage.\n- [ ] High testing standards (FuzzTesting, AddressSanitizers, etc).\n- [x] Lightweight \u0026 easy to include - A single header \u0026 source file.\n- [x] Easy to use API (see usage).\n- [ ] Integration with package managers (`conan` \u0026 `vcpkg`).\n\n## Usage\n\nHere's an example of using the `base64pp` library for a round-trip encoding\nof a file given as an argument.\n\n```cpp\n#include \"base64pp.h\"\n\n#include \u003citerator\u003e\n#include \u003ciostream\u003e\n#include \u003cfstream\u003e\n#include \u003cvector\u003e\n\nint main(int argc, char** argv)\n{\n  if (argc != 2)\n  {\n    std::cout \u003c\u003c \"Usage: program FILE_PATH\\n\"; \n  }\n\n  std::ifstream file_to_encode{argv[1]};\n  std::vector\u003cstd::uint8_t\u003e const bytes{std::istreambuf_iterator\u003cstd::uint8_t\u003e{file_to_encode}, {}};\n  \n  auto const base64_str = base64pp::encode({begin(bytes), end(bytes)});\n  std::cout \u003c\u003c base64_str \u003c\u003c '\\n';\n\n  // decoding \u0026 testing for equality\n  auto const decoded_bytes = base64::decode(base64_str);\n  if (!decoded_bytes)\n  {\n    std::cout \u003c\u003c \"could not decode.\\n\";\n  }\n\n  return *decoded_bytes == bytes;\n}\n```\n\n## Installation\n\nCurrently, you can use this library in a few different ways. Although\nlimited, I am working on making `base64pp` easily accessible through\npackage managers.\n\n### Raw Includes\n\nBuild the project (seebuild section), and make sure you link against\n`base64pp`, while also copying the header `base64pp/include/base64pp` to\nyour build system.\n\n### CMake\n\nAs of now, you can either include this project into your `CMakeLists.txt`\nvia `FetchContent{Declare,MakeAvailable}`, via submodule, or copying\nthe directory `base64pp` into your own project.\n\nHowever, if you are including the project with submodule or copying\nthe `base64pp` directory, make sure to call\n`add_subdirectory(path-to/base64pp)` in your `CMakeLists.txt`.\n\n### Package Managers\n\nThe plan is to make this library available through package managers.\n\nCurrently, I'm working on getting a working `conan` package for this\nrepo. If you feel like you could help, feel free to create a fork and\na PR!\n\n\n## Building The Project\n\nThis project can be build with CMake. Make sure you have a\nrecent enough version of CMake (\u003e= 3.21).\n\nIn addition, we build with the C++20 standard, so make sure\nyour compiler supports this version.\n\n### project dependencies\nBase64pp doesn't rely on any third-party libraries per se,\nbut the unit tests were implemented with GTest. However,\nthe dependencies were managed with [Conan](https://conan.io)\nso you do need to install that first.\n\nYou can use the following script to install `conan` dependencies:\n\n```bash\n./scripts/helpers/conan-install.sh [Debug|Release]\n```\n\n### Build Instructions\n\nRun the build bash script provided in the repo. This\nassumes you have installed `conan` dependencies.\n\nOn Linux, call:\n\n```bash\ncd ${PROJECT_ROOT_DIR}\n./scripts/build-x86-64.sh unix-rel\n``` \n\nOn Powershell (Windows), you can call:\n```pwsh\n.\\scripts\\build_win_x64.ps1 -Preset vs2022-rel\n```\n\nNote that `unix-rel` and `vs2022-rel` are presets provided\nin the `CMakePresets.json`. Take a look at the build scripts\nfor more info.\n\n**All the build files will be compiled to `build/\u003cPRESET-NAME\u003e/base64pp`.**\n\n## License\nBase64pp is licensed under the MIT license. See the LICENSE file for more details.\n\n## Contributions\n\nContributions to base64pp are welcome. To contribute, please fork the repository,\nmake your changes, and submit a pull request. Please ensure that your code follows\nthe existing coding style and conventions, and include appropriate tests where\nnecessary.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatheusgomes28%2Fbase64pp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatheusgomes28%2Fbase64pp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatheusgomes28%2Fbase64pp/lists"}