コード例 #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;
 }