C# Class ICSharpCode.SharpZipLib.Checksum.Crc32

CRC-32 with reversed data and unreversed output
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0. Polynomials over GF(2) are represented in binary, one bit per coefficient, with the lowest powers in the most significant bit. Then adding polynomials is just exclusive-or, and multiplying a polynomial by x is a right shift by one. If we call the above polynomial p, and represent a byte as the polynomial q, also with the lowest power in the most significant bit (so the byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, where a mod b means the remainder after dividing a by b. This calculation is done using the shift-register method of multiplying and taking the remainder. The register is initialized to zero, and for each incoming bit, x^32 is added mod p to the register if the bit is a one (where x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by x (which is shifting right by one and adding x^32 mod p if the bit shifted out is a one). We start with the highest power (least significant bit) of q and repeat for all eight bits of q. The table is simply the CRC of all possible eight bit values. This is all the information needed to generate CRC's on data a byte at a time for all combinations of CRC register values and incoming bytes.
Inheritance: IChecksum
Datei anzeigen Open project: icsharpcode/SharpZipLib Class Usage Examples

Public Methods

Method Description
Crc32 ( ) : System

Initialise a default instance of

Reset ( ) : void

Resets the CRC data checksum as if no update was ever called.

Update ( byte buffer ) : void

Updates the CRC data checksum with the bytes taken from a block of data.

Update ( byte buffer, int offset, int count ) : void

Update CRC data checksum based on a portion of a block of data

Update ( int bval ) : void

Updates the checksum with the int bval.

Reversed Data = true

Private Methods

Method Description
ComputeCrc32 ( uint oldCrc, byte bval ) : uint

Method Details

Crc32() public method

Initialise a default instance of
public Crc32 ( ) : System
return System

Reset() public method

Resets the CRC data checksum as if no update was ever called.
public Reset ( ) : void
return void

Update() public method

Updates the CRC data checksum with the bytes taken from a block of data.
public Update ( byte buffer ) : void
buffer byte Contains the data to update the CRC with.
return void

Update() public method

Update CRC data checksum based on a portion of a block of data
public Update ( byte buffer, int offset, int count ) : void
buffer byte Contains the data to update the CRC with.
offset int The offset into the buffer where the data starts
count int The number of data bytes to update the CRC with.
return void

Update() public method

Updates the checksum with the int bval.
Reversed Data = true
public Update ( int bval ) : void
bval int /// the byte is taken as the lower 8 bits of bval ///
return void