public static void Main()
ParseEncodedToken("vnoEqgAAAA1ldTEubG9yaW90LmlvsXM3cACDSpbi9-pi8RbHZQ==",1);
static void ParseEncodedToken(string Base64UrlEncodedString, int appId)
string Base64String = CleanBase64(Base64UrlEncodedString);
byte[] data = System.Convert.FromBase64String(Base64String);
string HexString = BitConverter.ToString(data).Replace("-", string.Empty);
Console.WriteLine(HexString + "\n");
string AppId = HexString.Substring(0,8);
string ServerIdLengthHex = HexString.Substring(8,8);
int ServerIdLength = (int)Convert.ToInt64(ServerIdLengthHex,16);
string ServerUrl = Hex2String(HexString.Substring(16,ServerIdLength*2));
string Token = HexString.Substring(16+ServerIdLength*2);
Console.WriteLine("AppId: " + AppId + "\n");
Console.WriteLine("ServerIdLengthHex: " + ServerIdLengthHex + "\n");
Console.WriteLine("ServerIdLength: " + ServerIdLength + "\n");
Console.WriteLine("ServerUrl: " + ServerUrl + "\n");
Console.WriteLine("Token: " + Token + "\n");
static string CleanBase64(string Base64Url)
Base64Url = Base64Url.Replace("-","+");
Base64Url = Base64Url.Replace("_","\\");
public static string Hex2String(string hex)
int count = hex.Length / 2;
for (s = 0; s < count; s++)
string zeichen = hex.Substring(s * 2, 2);
result += (char)Convert.ToUInt16(zeichen, 16);