public Encryptor(string method, string password) { MD5 md5 = System.Security.Cryptography.MD5.Create(); byte[] inputBytes = System.Text.Encoding.UTF8.GetBytes(password); byte[] hash = md5.ComputeHash(inputBytes); encryptCTX = IntPtr.Zero; decryptCTX = IntPtr.Zero; this.method = method; this.password = password; if (method != null && method.ToLowerInvariant().Equals("rc4")) { Console.WriteLine("init rc4"); rc4 = new RC4(); encryptTable = rc4.EncryptInitalize(hash); decryptTable = rc4.EncryptInitalize(hash); } else if (method == "table" || method == "" || method == null) { Console.WriteLine("init table"); // TODO endian var a = BitConverter.ToUInt64(hash, 0); for (int i = 0; i < 256; i++) { encryptTable[i] = (byte)i; } for (int i = 1; i < 1024; i++) { encryptTable = mergeSort(encryptTable, a, i); } for (int i = 0; i < 256; i++) { decryptTable[encryptTable[i]] = (byte)i; } } else { initKey(password, method); } }