目标是将 base64 解码为二进制。
我试过的
public static byte[] Decode(string input)
{
string cleanedInput = Regex.Replace(input, @"[^a-zA-Z0-9\+/=]", ""); // Entfernt alle ungültigen Zeichen
int paddingLength = cleanedInput.Length % 4;
if (paddingLength != 0)
{
paddingLength = 4 - paddingLength;
StringBuilder paddedInput = new StringBuilder(cleanedInput);
paddedInput.Append(new string('=', paddingLength));
cleanedInput = paddedInput.ToString();
}
byte[] bytes = Convert.FromBase64String(cleanedInput); // Konvertiert den bereinigten String in Bytes
return bytes;
}
我明白了
The input is not a valid Base-64 string as it contains a non-base 64 character.
使用https://www.base64decode.org/我可以很容易地解码相同的字符串。