internal override Stream DecryptEntry(Stream input, PazEntry entry) { if (Version < 1) { using (input) { var data = new byte[entry.AlignedSize]; input.Read(data, 0, data.Length); for (int i = 0; i < data.Length; ++i) { data[i] = MovKey[data[i]]; } return(new BinMemoryStream(data, entry.Name)); } } var key = new byte[0x100]; for (int i = 0; i < 0x100; ++i) { key[i] = (byte)(MovKey[i] ^ entry.Key[i % entry.Key.Length]); } var rc4 = new Rc4Transform(key); var block = rc4.GenerateBlock((int)Math.Min(0x10000, input.Length)); return(new ByteStringEncryptedStream(input, block)); }
internal override Stream DecryptEntry(Stream input, PazEntry entry) { input = new InputCryptoStream(input, Encryption.CreateDecryptor()); var key = entry.Key; if (null == key) { return(input); } var rc4 = new Rc4Transform(key); if (Version >= 2) { uint crc = Crc32.Compute(key, 0, key.Length); int skip_rounds = (int)(crc >> 12) & 0xFF; for (int i = 0; i < skip_rounds; ++i) { rc4.NextByte(); } } return(new InputCryptoStream(input, rc4)); }
internal abstract Stream DecryptEntry(Stream input, PazEntry entry);