Kotucode's Base 项目
本项目提供了 C++ 接口的 Base62 和 Base64 相关的编解码方法。
载入中...
搜索中...
未找到
kotucode::base::base64 命名空间参考

函数

template<typename Alphabets = alphabet::base64>
std::string encode (const std::string &binary_data)
 将二进制数据编码为 Base64 字符串。
template<typename Alphabets = alphabet::base64>
std::string decode (const std::string &base_string)
 将 Base64 编码字符串解码为原始二进制数据。
template<typename Alphabets = alphabet::base64>
std::string pad (const std::string &base_string)
 给修剪过的 Base64 编码字符串重新添加上填充。
template<typename Alphabets = alphabet::base64>
std::string trim (const std::string &base_string)
 修剪 Base64 编码字符串,去掉末尾的填充。

函数说明

◆ decode()

template<typename Alphabets = alphabet::base64>
std::string kotucode::base::base64::decode ( const std::string & base_string)

将 Base64 编码字符串解码为原始二进制数据。

模板参数
Alphabets编码字符集类型,默认为 alphabet::base64。
参数
base_string待解码的字符串。
返回
解码后的二进制数据;若包含非法字符则返回空字符串。

◆ encode()

template<typename Alphabets = alphabet::base64>
std::string kotucode::base::base64::encode ( const std::string & binary_data)

将二进制数据编码为 Base64 字符串。

模板参数
Alphabets编码字符集类型,默认为 alphabet::base64。
参数
binary_data待编码的二进制字符串。
返回
编码后的字符串。

◆ pad()

template<typename Alphabets = alphabet::base64>
std::string kotucode::base::base64::pad ( const std::string & base_string)

给修剪过的 Base64 编码字符串重新添加上填充。

注意
当填充符长度大于 1 时, 请确保传入的 base_string 一定是修剪过后的。 否则可能会获得错误的结果。 例如使用 base64url 时传入 "YSB2YT8%3d" 输出 "YSB2YT8%3d%3d%3d".
模板参数
Alphabets编码字符集类型,默认为 alphabet::base64。
参数
base_string修剪过的 Base64 编码字符串。
返回
重新添加上填充的 Base64 编码字符串。

◆ trim()

template<typename Alphabets = alphabet::base64>
std::string kotucode::base::base64::trim ( const std::string & base_string)

修剪 Base64 编码字符串,去掉末尾的填充。

模板参数
Alphabets编码字符集类型,默认为 alphabet::base64。
参数
base_string完整的 Base64 编码字符串。
返回
修剪过的 Base64 编码字符串。
注解
在一些 url-safe 或者 filename-safe 的 Base64 标准中, 会要求去掉末尾的填充字符。