Пример #1
0
        public override byte ReadByte()
        {
            byte result = base.ReadByte();

            if (autoAlignOn)
            {
                bytesSinceAlignStart++;
            }

            if (checksumCalculator?.CalculateForDecryptedData == false)
            {
                checksumCalculator?.AddByte(result);
            }

            if (xorKey.HasValue)
            {
                result = (byte)(result ^ xorKey.Value);
            }

            if (checksumCalculator?.CalculateForDecryptedData == true)
            {
                checksumCalculator?.AddByte(result);
            }

            return(result);
        }
Пример #2
0
        public override void Write(byte value)
        {
            if (checksumCalculator?.CalculateForDecryptedData == true)
            {
                checksumCalculator?.AddByte(value);
            }

            if (xorKey.HasValue)
            {
                value = (byte)(value ^ xorKey.Value);
            }

            if (checksumCalculator?.CalculateForDecryptedData == false)
            {
                checksumCalculator?.AddByte(value);
            }

            base.Write(value);

            if (autoAlignOn)
            {
                bytesSinceAlignStart++;
            }
        }