# modp_b64 **Repository Path**: wblong/modp_b64 ## Basic Information - **Project Name**: modp_b64 - **Description**: base64 encode & decode - **Primary Language**: C++ - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-10-21 - **Last Updated**: 2026-07-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Base64 ## Demo ```cpp #include #include #include #include namespace { std::vector decodeBase64(gsl::span data) { std::vector result(modp_b64_decode_len(data.size())); size_t resultLength = modp_b64_decode( reinterpret_cast(result.data()), reinterpret_cast(data.data()), data.size() ); if (resultLength == size_t(-1)) { result.clear(); result.shrink_to_fit(); } else { result.resize(resultLength); } return result; } } int main(){ const std::filesystem::path ctm_file = TestPath / "ctm"; std::vector ctm_encode_data = readFile(ctm_file); gsl::spantmp_data(reinterpret_cast(ctm_encode_data.data()), ctm_encode_data.size()); std::vectorctm_decode_data= decodeBase64(tmp_data); const std::filesystem::path ctm_file_decode = TestPath / "ctm_decode"; gsl::span < std::byte> ctm (reinterpret_cast(ctm_file_decode.data()), ctm_file_decode.size()); writeFile(ctm_file_decode, ctm); return 0; } ``` ## Usage ``` //Root.CMakeLists.txt add_subdirectory(modp_b64) install(TARGETS modp_b64) ``` ``` //Demo.CMakeLists.txt target_link_libraries(Demo PUBLIC PRIVATE modp_b64 ) ```