Quantcast
Viewing all articles
Browse latest Browse all 4845

New Post: Validating a digitally signed JSon Web Token with a public key

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)
{
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!
}
}

Viewing all articles
Browse latest Browse all 4845


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>