using Microsoft.AspNetCore.WebUtilities;
public static void Main()
var s = "W0JFTEVHX05SX109IkU4NDE3NyI";
var o = @"[BELEG_NR_]=""E84177""";
Console.WriteLine("Decoding Start ==============================================");Console.WriteLine("\r\n");
Console.WriteLine(".NET 4.8 - FromBase64String:");
Console.WriteLine($@"""{s}="" => {Encoding.UTF8.GetString(Convert.FromBase64String($"{s}="))}");
try { Console.WriteLine($@"""{s}"" => {Encoding.UTF8.GetString(Convert.FromBase64String(s))}"); }
catch (Exception ex) { Console.WriteLine($@"""{s}"" => Error: {ex.Message}"); }
try { Console.WriteLine($@"""{s}%3d"" => {Encoding.UTF8.GetString(Convert.FromBase64String($"{s}%3d"))}"); }
catch (Exception ex) { Console.WriteLine($@"""{s}%3d"" => Error: {ex.Message}"); }
Console.WriteLine("\r\n");
Console.WriteLine(".NET CORE - Base64UrlDecode:");
Console.WriteLine($@"""{s}="" => {Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode($"{s}="))}");
Console.WriteLine($@"""{s}"" => {Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(s))}");
try { Console.WriteLine($@"""{s}%3d"" => {Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode($"{s}%3d"))}"); }
catch (Exception ex) { Console.WriteLine($@"""{s}%3d"" => Error: {ex.Message}"); }
Console.WriteLine("\r\n");
Console.WriteLine("Decoding End ================================================");
Console.WriteLine("\r\n");
Console.WriteLine("Encoding Start ==============================================");
Console.WriteLine("\r\n");
Console.WriteLine(".NET 4.8 - ToBase64String:");
Console.WriteLine($@"{o} => {Convert.ToBase64String(Encoding.UTF8.GetBytes(o))}");
Console.WriteLine("\r\n");
Console.WriteLine(".NET CORE - Base64UrlEncode:");
Console.WriteLine($@"{o} => {WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(o))}");
Console.WriteLine("\r\n");
Console.WriteLine("Encoding End ================================================");