Пример #1
0
        private static UInt32 InternalProcessStream(Stream stream, long?maxLength, int?bufferSize)
        {
            Crc32Processor processor = new Crc32Processor();

            byte[] buffer = new byte[bufferSize.GetValueOrDefault(4096)];

            long totalBytesRead = 0;

            while (true)
            {
                int bytesRead = stream.Read(buffer, 0, maxLength.HasValue ? (int)Math.Min(buffer.Length, maxLength.Value - totalBytesRead) : buffer.Length);
                processor.Process(buffer, 0, bytesRead);
                if (maxLength.HasValue)
                {
                    totalBytesRead += bytesRead;
                    if (totalBytesRead >= maxLength.Value)
                    {
                        break;
                    }
                }
                else if (bytesRead == 0)
                {
                    break;
                }
            }
            return(processor.Current);
        }
Пример #2
0
        public static UInt32 Process(byte[] buffer, int startIndex, int length)
        {
            Crc32Processor processor = new Crc32Processor();

            processor.Process(buffer, startIndex, length);
            return(processor.Current);
        }
Пример #3
0
        public static UInt32 Process(byte[] bytes)
        {
            Crc32Processor processor = new Crc32Processor();

            processor.Process(bytes);
            return(processor.Current);
        }
Пример #4
0
        private static UInt32 InternalProcessStream(Stream stream, long? maxLength, int? bufferSize)
        {
            Crc32Processor processor = new Crc32Processor();
            byte[] buffer = new byte[bufferSize.GetValueOrDefault(4096)];

            long totalBytesRead = 0;
            while (true)
            {
                int bytesRead = stream.Read(buffer, 0, maxLength.HasValue ? (int)Math.Min(buffer.Length, maxLength.Value - totalBytesRead) : buffer.Length);
                processor.Process(buffer, 0, bytesRead);
                if (maxLength.HasValue)
                {
                    totalBytesRead += bytesRead;
                    if (totalBytesRead >= maxLength.Value) break;
                }
                else if (bytesRead == 0)
                {
                    break;
                }
            }
            return processor.Current;
        }
Пример #5
0
 public static UInt32 Process(byte[] buffer, int startIndex, int length)
 {
     Crc32Processor processor = new Crc32Processor();
     processor.Process(buffer, startIndex, length);
     return processor.Current;
 }
Пример #6
0
 public static UInt32 Process(byte[] bytes)
 {
     Crc32Processor processor = new Crc32Processor();
     processor.Process(bytes);
     return processor.Current;
 }