private byte[] DetermineKey(Stream input) { foreach (var key in Keys) { using var xorStream = new XorStream(input, key) { Position = 2 }; var value = xorStream.ReadByte(); if (value == 0) { return(key); } } return(null); }
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------ internal CircuitInfo(Stream stream) { XorStream xorStream = new XorStream(stream, _key); Name = xorStream.ReadFixedString(_maxNameLength); DisplayName = xorStream.ReadFixedString(_maxDisplayNameLength); ImageFile1 = xorStream.ReadFixedString(_maxImageFile1Length); ImageFile2 = xorStream.ReadFixedString(_maxImageFile2Length); ImageFile3 = xorStream.ReadFixedString(_maxImageFile3Length); Flags = (CircuitFlags)xorStream.ReadByte(); Version = (byte)xorStream.ReadByte(); ID = (byte)xorStream.ReadByte(); byte alignment1 = (byte)xorStream.ReadByte(); Length = xorStream.ReadInt32(); Laps = (byte)xorStream.ReadByte(); Level = (byte)xorStream.ReadByte(); ushort alignment2 = xorStream.ReadUInt16(); uint runtime = xorStream.ReadUInt32(); }