CRC-32 ExampleCRC is one of the most reliable error detection schemes and can detect up to 95.5% of all errors. The most commonly used code is the CRC-32 standard code which is defined by the CCITT, and will give a 32-bit CRC signature (8 hex characters). This signature is normally appended onto the data, and then checked when the data is read. If the CRC-32 check differs from the stored value, there is likely to be an error in the data. [Theory][Background] The basic idea of a CRC can be illustrated using an example. Suppose the transmitter and receiver were both to agree that the numerical value sent by the transmitter would always be divisible by 9. Then should the receiver get a value which was not divisible by 9 would know it knows that there had been an error. For example, if a value of 32 were to be transmitted it could be changed to 320 so that the transmitter would be able to add to the least significant digit, making it divisible by 9. In this case the transmitter would add 4, making 324. If this transmitted value were to be corrupted in transmission then there would only be a 10% chance that an error would not be detected. Other non-crypto hashes: [Meow][xxHash][Siphash][FVN][Murmur][Spooky][o1hash][CRC-32][wyhash][CityHash][FarmHash][Non-crypto][C/C++: CityHash, Farmhash, MUM, xxHash, Spooky and Murmur][Pearson][C++: t1ha][C++: Spooky][C++: xxHash][C++: MUM][C++: FNV][C++: MetroHash][C++: CityHash][C++: FarmHash][C++: Murmur][C++: Halftimehash][C++: HighwayHash][C++: SipHash][C++: ClHash][C++: FalkHash][C++: wyHash][C++: Fibonacci][C++: Lookup3] Other non-crypto hashes: [Meow][xxHash][Siphash][FVN][Murmur][Spooky][o1hash][CRC-32][wyhash][CityHash][FarmHash][Non-crypto][C/C++: CityHash, Farmhash, MUM, xxHash, Spooky and Murmur][Pearson][C++: t1ha][C++: Spooky][C++: xxHash][C++: MUM][C++: FNV][C++: MetroHash][C++: CityHash][C++: FarmHash][C++: Murmur][C++: Halftimehash] The results are then:
|
Examples
- Try "The quick brown fox jumps over the lazy dog". Try!, which should give a CRC-32 value of: 414fa339 Check
- Try "Test vector from febooti.com". Try!, which should give a CRC-32 value of: 0c877f61Check
- Try "". Try!, which should give a CRC-32 value of 00000000Check
Sample code
This page uses the code from:
// Uses call to code used in http://damieng.com/blog/2006/08/0/calculating_crc32_in_c_and_net public void checkCrc(string message) { Crc32 crc32 = new Crc32(); String hash = String.Empty; System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); byte [] data = encoding.GetBytes(message); foreach (byte b in crc32.ComputeHash(data)) hash += b.ToString("x2").ToLower(); hash1 = hash; }