namespace HabboRC4_V24Release { using System; using System.Text; public class Habbo_V24_Crypto { private string[] di = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" }; private int i; private int j; private int[] key = new int[0x100]; private int premixCount = 0x11; private string premixString = "1wz8rzgiv87708l9oi7ot8l9smdqv5yvzz8tavkyuoi9p3kgrrq7r5p53kchnb5hly8jkfx5hsoo6imx8o5ktczwdst8dooa7r331wkrw8zi8789io89mq5vztvyo93gr755khbhyjf5soixokcws8oar3wr"; private int[] table = new int[0x100]; public Habbo_V24_Crypto() { this.initCalculators(); this.init(); this.premixTable(this.premixString, this.premixCount); } public string deciphper(string data) { StringBuilder builder = new StringBuilder(data.Length); int num = 0; int num2 = 0; for (int i = 0; i < data.Length; i += 2) { this.i = (this.i + 1) % 0x100; this.j = (this.j + this.table[this.i]) % 0x100; num = this.table[this.i]; this.table[this.i] = this.table[this.j]; this.table[this.j] = num; num2 = this.table[(this.table[this.i] + this.table[this.j]) % 0x100]; num = Convert.ToInt32(this.JavaSubstring(data, i, i + 2), 0x10); builder = builder.Append((char) (num ^ num2)); } return builder.ToString(); } public string encipher(string data) { StringBuilder builder = new StringBuilder(data.Length * 2); int num = 0; int num2 = 0; for (int i = 0; i < data.Length; i++) { this.i = (this.i + 1) % 0x100; this.j = (this.j + this.table[this.i]) % 0x100; num = this.table[this.i]; this.table[this.i] = this.table[this.j]; this.table[this.j] = num; num2 = this.table[(this.table[this.i] + this.table[this.j]) % 0x100]; int num4 = data.Substring(i, 1).ToCharArray()[0] ^ num2; if (num4 <= 0) { builder.Append("00"); } else { builder.Append(this.di[(num4 >> 4) & 15]); builder.Append(this.di[num4 & 15]); } } return builder.ToString(); } private static string GenerateRandomString(int Length) { string str = ""; Random random = new Random(); for (int i = 0; i < Length; i++) { str = str + ((char) random.Next(0x41, 0x7a)).ToString(); } return str; } private void init() { for (int i = 0; i <= 0xfe; i++) { this.table[i] = i + 1; } this.table[0] = 0; this.table[0xff] = 1; } private void initCalculators() { this.i = 0; this.j = 0; } public string JavaSubstring(string dataIn, int start, int end) { return dataIn.Substring(start, end - start); } internal void premixTable(string datain, int count) { for (int i = 0; i < count; i++) { this.encipher(datain); } } public string rePremix() { int count = 10; string datain = GenerateRandomString(20); this.premixTable(datain, count); return ""; } } }