本项目提供了 C++ 接口的 Base62 和 Base64 相关的编解码方法。
功能概述
- Base62 编解码 — 使用 0-9、A-Z、a-z 共 62 个字符进行编解码
- Base64 编解码 — 标准 Base64 编解码支持
- Base64URL 编解码 — URL 安全的 Base64 编解码
安装
本项目是纯头文件库(Header-Only),复制 include 目录下的 base.hpp 文件到你的项目中即可使用。
你也可以使用 CMake 的 FetchContent 进行导入。
include(FetchContent)
FetchContent_Declare(base
GIT_REPOSITORY https://github.com/kotucode/base.git
GIT_TAG main
)
FetchContent_MakeAvailable(base)
target_link_libraries(my_app PRIVATE base)
快速开始
int main() {
auto data = "Hello World!";
return 0;
}
std::string decode(const std::string &base_string)
将 Base62 编码字符串解码为原始二进制数据。
定义 base.hpp:301
std::string encode(const std::string &binary_data)
将二进制数据编码为 Base62 字符串。
定义 base.hpp:289
std::string encode(const std::string &binary_data)
将二进制数据编码为 Base64 字符串。
定义 base.hpp:442
std::string decode(const std::string &base_string)
将 Base64 编码字符串解码为原始二进制数据。
定义 base.hpp:454
Base64 编码字符集, url-safe 并且 filename-safe, 提供合法的 Base64 字符的正向与反向映射表及其填充字符串。
定义 base.hpp:98
API 文档
项目文档由 Doxygen 生成,使用浏览器打开项目下的 docs/html/index.html 即可阅读文档。
许可证
本项目基于 MIT 许可证开源,详见 LICENSE 文件。