27 private const uint CrcSeed = 0xFFFFFFFF;
31 #region Constructors and Destructors
40 Crc32Table =
new uint[256];
41 for (uint i = 0; i < Crc32Table.Length; i++)
45 for (
int j = 0; j < 8; j++)
49 c = 3988292384 ^ (c >> 1);
63 #region Public Properties
68 public static uint[] Crc32Table {
get;
private set; }
73 public uint Value {
get; set; }
77 #region Public Methods and Operators
95 this.Value ^= CrcSeed;
96 this.Value = Crc32Table[(this.Value ^ value) & 0xFF] ^ (this.Value >> 8);
97 this.Value ^= CrcSeed;
116 throw new ArgumentNullException(
"buffer");
121 throw new ArgumentOutOfRangeException(
"count",
"Count cannot be less than zero");
124 if (offset < 0 || offset + count > buffer.Length)
126 throw new ArgumentOutOfRangeException(
"offset");
129 this.Value ^= CrcSeed;
133 this.Value = Crc32Table[(this.Value ^ buffer[offset++]) & 0xFF] ^ (this.Value >> 8);
136 this.Value ^= CrcSeed;
void Reset()
Resets the CRC32 data checksum as if no update was ever called.
void Update(byte[] buffer, int offset, int count)
Adds the byte array to the data checksum.
void Update(int value)
Updates the checksum with the int bval.
Compression
Compression method enumeration