What causing this “Invalid length for a Base-64 char array”

前端 未结 12 2039
走了就别回头了
走了就别回头了 2020-11-28 02:56

I have very little to go on here. I can\'t reproduce this locally, but when users get the error I get an automatic email exception notification:



        
12条回答
  •  日久生厌
    2020-11-28 03:31

    In addition to @jalchr's solution that helped me, I found that when calling ATL::Base64Encode from a c++ application to encode the content you pass to an ASP.NET webservice, you need something else, too. In addition to

    sEncryptedString = sEncryptedString.Replace(' ', '+'); 
    

    from @jalchr's solution, you also need to ensure that you do not use the ATL_BASE64_FLAG_NOPAD flag on ATL::Base64Encode:

     BOOL bEncoded = Base64Encode(lpBuffer,
                        nBufferSizeInBytes,
                        strBase64Encoded.GetBufferSetLength(base64Length),
                        &base64Length,ATL_BASE64_FLAG_NOCRLF/*|ATL_BASE64_FLAG_NOPAD*/);
    

提交回复
热议问题