diff --git a/coding/base64.cpp b/coding/base64.cpp index 86b2346c93..d5d886c909 100644 --- a/coding/base64.cpp +++ b/coding/base64.cpp @@ -10,8 +10,18 @@ typedef transform_width, 8, 6 > binar namespace base64 { - string encode(string const & rawBytes) + string encode(string rawBytes) { + // http://boost.2283326.n4.nabble.com/boost-archive-iterators-base64-from-binary-td2589980.html + switch (rawBytes.size() % 3) + { + case 1: + rawBytes.push_back('0'); + case 2: + rawBytes.push_back('0'); + break; + } + return string(base64_t(rawBytes.begin()), base64_t(rawBytes.end())); } diff --git a/coding/base64.hpp b/coding/base64.hpp index 35003b12e0..f30afc9708 100644 --- a/coding/base64.hpp +++ b/coding/base64.hpp @@ -4,6 +4,6 @@ namespace base64 { - string encode(string const & rawBytes); + string encode(string rawBytes); string decode(string const & base64Chars); }