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

前端 未结 12 2025
走了就别回头了
走了就别回头了 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:12

    Try this:

    public string EncodeBase64(string data)
    {
        string s = data.Trim().Replace(" ", "+");
        if (s.Length % 4 > 0)
            s = s.PadRight(s.Length + 4 - s.Length % 4, '=');
        return Encoding.UTF8.GetString(Convert.FromBase64String(s));
    }
    

提交回复
热议问题