19 #include <boost/algorithm/string.hpp>
20 #include <boost/archive/iterators/base64_from_binary.hpp>
21 #include <boost/archive/iterators/binary_from_base64.hpp>
22 #include <boost/archive/iterators/transform_width.hpp>
27 inline std::string
decode_base64(
const std::string& val,
bool trim_nulls) {
30 using namespace boost::archive::iterators;
31 using It = transform_width<binary_from_base64<std::string::const_iterator>, 8, 6>;
34 return std::string(It(val.begin()), It(val.end()));
36 return boost::algorithm::trim_right_copy_if(
37 std::string(It(std::begin(val)), It(std::end(val))),
38 [](
char c) {
return c ==
'\0'; });
46 using namespace boost::archive::iterators;
47 using It = base64_from_binary<transform_width<std::string::const_iterator, 6, 8>>;
48 auto tmp = std::string(It(std::begin(val)), It(std::end(val)));
49 return tmp.append((3 - val.size() % 3) % 3,
'=');
std::string decode_base64_uri(const std::string &data, bool trim_nulls)
std::string decode_base64(const std::string &val, bool trim_nulls)
static std::string encode_base64(const std::string &val)