Inheritance diagram for ICSharpCode::SharpZipLib::Checksums::Crc32:
Public Member Functions | |
void | Reset () |
Resets the CRC32 data checksum as if no update was ever called. | |
void | Update (int bval) |
Updates the checksum with the int bval. | |
void | Update (byte[] buffer) |
Updates the checksum with the bytes taken from the array. | |
void | Update (byte[] buf, int off, int len) |
Adds the byte array to the data checksum. | |
Properties | |
long | Value |
Returns the CRC32 data checksum computed so far. | |
Static Private Member Functions | |
static internal uint | ComputeCrc32 (uint oldCrc, byte bval) |
Private Attributes | |
uint | crc = 0 |
The crc data checksum so far. | |
Static Private Attributes | |
static readonly uint | CrcSeed = 0xFFFFFFFF |
static readonly uint[] | CrcTable |
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.
Definition at line 67 of file CRC32.cs.
|
|
|
Resets the CRC32 data checksum as if no update was ever called.
Implements ICSharpCode::SharpZipLib::Checksums::IChecksum. |
|
Adds the byte array to the data checksum.
Implements ICSharpCode::SharpZipLib::Checksums::IChecksum. |
|
Updates the checksum with the bytes taken from the array.
Implements ICSharpCode::SharpZipLib::Checksums::IChecksum. |
|
Updates the checksum with the int bval.
Implements ICSharpCode::SharpZipLib::Checksums::IChecksum. Definition at line 162 of file CRC32.cs. Referenced by ICSharpCode::SharpZipLib::Zip::ZipFile::TestArchive(). |
|
The crc data checksum so far.
|
|
|
|
|
|
Returns the CRC32 data checksum computed so far.
Implements ICSharpCode::SharpZipLib::Checksums::IChecksum. Definition at line 139 of file CRC32.cs. Referenced by ICSharpCode::SharpZipLib::Zip::ZipFile::TestArchive(). |