Hello Steve and thank you! Found an annoying thing with from_base64. One must right-pad the string to make the length evenly divisible by 4.
std::string base64Decode(const std::wstring& encoded)
{
std::string base64Decode(const std::wstring& encoded)
{
try
{
std::wstring toPossiblyPad(encoded); //copy!
toPossiblyPad += std::wstring(toPossiblyPad.length() % 4, L'=');
std::vector<unsigned char> decoded = utility::conversions::from_base64(toPossiblyPad.c_str());
std::string strDecoded(decoded.begin(), decoded.end());
return strDecoded;
}
catch (std::exception ex)
{
//TODO!
}
catch (...)
{
//TODO!
}
}