using System.Security.Cryptography;
public static void Validate()
public static bool CheckKey(string key, out uint id, out uint randomNumber)
byte[] data = Encoder.Decode(key);
byte[] data2 = RC4.Cipher("SupportIndieDevelopersWeNeedIt", data);
for (int i = 0; i < 32; i++)
uint num = (uint)((uint)Encoder.ReadBit(data2, 0 + i * 2) << i);
for (int j = 0; j < 32; j++)
uint num2 = (uint)((uint)Encoder.ReadBit(data2, 1 + j * 2) << j);
uint num3 = (uint)((int)Encoder.ReadByte(data2, 8) << 8 | (int)Encoder.ReadByte(data2, 9));
return num4 % 89U == 0U && (uint)Encoder.Digest(data2, 8) == num3;
private static void WriteBit(byte[] data, int loc, byte bit)
data[num3] |= (byte)((bit & 1) << num2);
private static byte ReadBit(byte[] data, int loc)
return (byte)(data[num] >> num2 & 1);
private static void WriteByte(byte[] data, int loc, byte b)
private static byte ReadByte(byte[] data, int loc)
private static ushort Digest(byte[] data, int l)
byte[] array = new byte[l];
Array.Copy(data, array, l);
MD5CryptoServiceProvider md5CryptoServiceProvider = new MD5CryptoServiceProvider();
byte[] array2 = md5CryptoServiceProvider.ComputeHash(array);
return (ushort)((int)array2[0] << 8 | (int)array2[1]);
public static string Encode(byte[] data)
string text = string.Empty;
for (int i = 0; i < data.Length; i++)
text += Encoder.AlphaMap((int)data[i]);
return Encoder.InsertDashes(text);
public static byte[] Decode(string data)
string text = Encoder.RemoveDashes(data);
byte[] array = new byte[text.Length / 2];
for (int i = 0; i < text.Length; i += 2)
array[i / 2] = Encoder.AlphaUnmap(c, c2);
private static string AlphaMap(int v)
int num = (int)((uint)(v & 240) >> 4 & 15U);
char c = Encoder.ALPHABET[num];
char c2 = Encoder.ALPHABET[num2];
string str = new string (c, 1);
string str2 = new string (c2, 1);
private static byte AlphaUnmap(char c1, char c2)
for (i = 0; i < Encoder.ALPHABET.Length; i++)
if (Encoder.ALPHABET[i] == c1)
byte b = (byte)((i & 15) << 4);
for (i = 0; i < Encoder.ALPHABET.Length; i++)
if (Encoder.ALPHABET[i] == c2)
return (byte)((int)b | (i & 15));
private static string InsertDashes(string data)
string text = string.Empty;
for (int i = 0; i < data.Length; i++)
if ((i + 1) % 4 == 0 && i != data.Length - 1)
private static string RemoveDashes(string data)
string text = string.Empty;
for (int i = 0; i < data.Length; i++)
string text2 = new string (data[i], 1);
public static char[] ALPHABET = new char[]{'J', 'N', 'D', 'M', 'G', 'H', 'B', 'K', 'F', 'C', 'P', 'Z', 'R', 'Y', 'W', 'X'};
public static byte[] Cipher(string skey, string sdata)
byte[] bytes = Encoding.UTF8.GetBytes(skey);
byte[] bytes2 = Encoding.UTF8.GetBytes(sdata);
return RC4.Cipher(bytes, bytes2);
public static byte[] Cipher(string skey, byte[] data)
byte[] bytes = Encoding.UTF8.GetBytes(skey);
return RC4.Cipher(bytes, data);
public static byte[] Cipher(byte[] key, byte[] data)
byte[] array = new byte[256];
for (int i = 0; i < 256; i++)
for (int j = 0; j < 256; j++)
num3 = (num3 + (int)array[j] + (int)key[j % num]) % 256;
byte[] array2 = new byte[num2];
for (int k = 0; k < num2; k++)
num5 = (num5 + (int)array[num4]) % 256;
array[num4] = array[num5];
array2[k] = (byte)(data[k] ^ array[(int)(array[num4] + array[num5]) % 256]);
public static byte[] Encrypt(byte[] pwd, byte[] data)
int[] array = new int[256];
int[] array2 = new int[256];
byte[] array3 = new byte[data.Length];
for (i = 0; i < 256; i++)
array[i] = (int)pwd[i % pwd.Length];
for (i = (num = 0); i < 256; i++)
num = (num + array2[i] + array[i]) % 256;
array2[num3] = array2[num];
int num4 = array2[(array2[num3] + array2[num]) % 256];
array3[i] = (byte)((int)data[i] ^ num4);
public static byte[] Decrypt(byte[] pwd, byte[] data)
return RC4.Encrypt(pwd, data);
public static string GetHexFromBytes(byte[] bytes)
char[] array = new char[bytes.Length * 2];
byte b = (byte)(bytes[i] >> 4);
array[num] = (char)((b <= 9) ? (b + 48) : (b + 55 + 32));
b = (byte)(bytes[i] & 15);
array[++num] = (char)((b <= 9) ? (b + 48) : (b + 55 + 32));
return new string (array);
public static byte[] GetBytesFromHex(string str)
if (str.Length == 0 || str.Length % 2 != 0)
byte[] array = new byte[str.Length / 2];
array[i] = (byte)(((c <= '9') ? (c - '0') : ((c <= 'Z') ? (c - 'A' + '\n') : (c - 'a' + '\n'))) << 4);
array2[num2] |= (byte)((c <= '9') ? (c - '0') : ((c <= 'Z') ? (c - 'A' + '\n') : (c - 'a' + '\n')));
public static void Main()
for (int i = 0; i < 5; i++)
bool flag = Encoder.CheckKey(key, out num, out num2);
Console.WriteLine("Hello World " + key + " " + flag);
private static Random random = new Random();
public static string RandomString(int length)
const string chars = "JNDMGHBKFCPZRYWX";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());