byte[] Decrypt(byte[] encryptedData) { const int KEY_LEN = 0x100; if (encryptedData.Length < KEY_LEN) { throw new ApplicationException("Invalid encrypted data length"); } var decryptedData = new byte[encryptedData.Length - KEY_LEN]; var pkt = PublicKey.GetRawData(PublicKeyBase.ToPublicKeyToken(module.Assembly.PublicKey)); if (pkt == null || pkt.Length == 0) { pkt = new byte[8]; } for (int i = 0, j = 0, ki = 0; i < decryptedData.Length; i++) { ki = (ki + 1) % (KEY_LEN - 1); j = (j + encryptedData[ki] + pkt[i % 8]) % (KEY_LEN - 1); var tmp = encryptedData[j]; encryptedData[j] = encryptedData[ki]; encryptedData[ki] = tmp; decryptedData[i] = (byte)(encryptedData[KEY_LEN + i] ^ encryptedData[(encryptedData[j] + encryptedData[ki]) % (KEY_LEN - 1)]); } return(decryptedData); }