Fix Base64 Decode Padding

Base64 decode padding calculation error
Fixes #415
This commit is contained in:
Yom Rawr
2019-11-21 09:04:03 +10:00
committed by GitHub
parent d6b7d49fec
commit ffeeaad22e
+1 -1
View File
@@ -31,7 +31,7 @@ namespace RuriLib.Functions.Formats
{
var toDecode = base64EncodedData.Replace(".", "");
var remainder = toDecode.Length % 4;
if (remainder != 0) toDecode = toDecode.PadRight(toDecode.Length + remainder, '=');
if (remainder != 0) toDecode = toDecode.PadRight(toDecode.Length + (4 - remainder), '=');
var base64EncodedBytes = System.Convert.FromBase64String(toDecode);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}