From 3c475f5027e870b19b9227375121b3b860eafb93 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Wed, 4 Jan 2023 20:22:36 +0100 Subject: Added os.cpp and base64.cpp --- base64.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 base64.cpp (limited to 'base64.cpp') diff --git a/base64.cpp b/base64.cpp new file mode 100644 index 0000000..d72dc52 --- /dev/null +++ b/base64.cpp @@ -0,0 +1,23 @@ +#include "base64.h" + +#include +#include +#include +#include + +std::string Reichwein::Base64::decode64(const std::string &val) +{ + using namespace boost::archive::iterators; + using It = transform_width, 8, 6>; + return boost::algorithm::trim_right_copy_if(std::string(It(std::begin(val)), It(std::end(val))), [](char c) { + return c == '\0'; + }); +} + +std::string Reichwein::Base64::encode64(const std::string &val) +{ + using namespace boost::archive::iterators; + using It = base64_from_binary>; + auto tmp = std::string(It(std::begin(val)), It(std::end(val))); + return tmp.append((3 - val.size() % 3) % 3, '='); +} -- cgit v1.2.3