Fixed problem in Base64Decode with some badly formatted tokens.

This commit is contained in:
ruri
2019-05-29 11:49:46 +02:00
parent 49663a0c67
commit 011aa0cd90
+4 -1
View File
@@ -727,7 +727,10 @@ namespace RuriLib
/// <returns>The decoded string</returns>
public static string Base64Decode(string base64EncodedData)
{
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
var toDecode = base64EncodedData.Replace(".", "");
var remainder = toDecode.Length % 4;
if (remainder != 0) toDecode = toDecode.PadRight(toDecode.Length + remainder, '=');
var base64EncodedBytes = System.Convert.FromBase64String(toDecode);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
#endregion