Cyclic redundancy check. An error checking mechanism used for verifying data integrity in serial protocols.
Questions tagged [crc]
1120 questions
11
votes
5 answers
Why use xor with a literal instead of inversion (bitwise not)
I have come across this CRC32 code and was curious why the author would choose to use
crc = crc ^ ~0U;
instead of
crc = ~crc;
As far as I can tell, they are equivalent.
I have even disassembled the two versions in Visual Studio 2010.
Not optimized…

nonsensickle
- 4,438
- 2
- 34
- 61
10
votes
1 answer
Is there a checksum algorithm that also supports "subtracting" data from it?
I have a system with roughly a 100 million documents, and I'd like to keep track of their modifications between mirrors. In order to exchange information about modifications effectively, I want to send information about modified documents by days,…

Andrejs Krasilnikovs
- 103
- 4
10
votes
2 answers
CRC-16 with 0xA001 polynomial
I would like to compute the CRC-16 checksum of a byte array, with 0xA001 polynomial. But I don't really know how to do it in Java, and how the given polynomial is used. Is it some kind of special value (0xA001)? Can you point me to a library that…

nihilist84
- 1,191
- 3
- 11
- 20
10
votes
3 answers
Is there a LINUX command line tool for CRC32C (Castagnoli)
I need to verify data using CRC32C, the Castagnoli variant of CRC32 calculation. I cannot find a self-contained command line utility anywhere that will calculate this to verify the values in question. CRC32? MD5? SHA? Check. CRC32C? You lose.
I need…

Mark Gerolimatos
- 2,424
- 1
- 23
- 33
10
votes
3 answers
Getting the CRC checksum of a byte array and adding it to that byte array
I have this byte array:
static byte[] buf = new byte[] { (byte) 0x01, (byte) 0x04, (byte)0x00, (byte)0x01,(byte)0x00, (byte) 0x01};
Now, the CRC checksum of this byte array is supposed to be 0x60, 0x0A. I want the Java code to recreate this…

GreenGodot
- 6,030
- 10
- 37
- 66
10
votes
4 answers
Is there a GUID alternative for distributed key generation?
My situation is :
I have a number of client applications, which is using local DB (MS SQL, MS Access - sorry, this is Enterprise system, I have to support legacy...)
I don't know anything of trend among clients - now it's ~10 but it may
be ~100 in…

Andriy Zakharko
- 1,623
- 2
- 16
- 37
9
votes
3 answers
CRC divisor calculation
Im trying to understand CRC and I'm getting confused as how to calculate the 'divisor'.
In the example on wikipedia the divisor is 11 (1011) for input of 11010011101100
11010011101100 000 <--- input left shifted by 3 bits
1011 <---…

tMC
- 18,105
- 14
- 62
- 98
9
votes
8 answers
CRC-CCITT 16-bit Python Manual Calculation
Problem
I am writing code for an embedded device. A lot of solutions out there for CRC-CCITT 16-bit calculations require libraries.
Given that using libraries is almost impossible and a drain on its resources, a function is required.
Possible…

Alex Stewart
- 730
- 3
- 12
- 30
9
votes
2 answers
Protobuf checksum (crc)
I am going to store some big objects into database (BLOB). And protobuf is, as I see it, one of the best candidates to serialize/deserialize BLOB. Despite it has binary format, it is still easy to read and to change its content (strings, integers,…

Sinatr
- 20,892
- 15
- 90
- 319
9
votes
4 answers
CRC-CCITT Implementation
I am using the following function to generate a CRC sum and it doesn't appear to be returning the same checksum when compared to online CRC-CCITT calculators.
This function specifically uses the XMODEM CRC generation with a 0x8408 polynomial with an…

AlphabetaPhi
- 91
- 1
- 1
- 2
9
votes
2 answers
_mm_crc32_u64 poorly defined
Why in the world was _mm_crc32_u64(...) defined like this?
unsigned int64 _mm_crc32_u64( unsigned __int64 crc, unsigned __int64 v );
The "crc32" instruction always accumulates a 32-bit CRC, never a 64-bit CRC (It is, after all, CRC32 not CRC64). …

David I. McIntosh
- 2,038
- 4
- 23
- 45
8
votes
3 answers
Java compatible cksum function
Is there any library/code in Java to calculate the 32-bit CRC of a stream of bytes in a way thats consistent with the cksum command in unix ?

Kowshik
- 1,541
- 3
- 17
- 25
8
votes
5 answers
How to calculate crc8 in C?
I have seen multiple implementation of crc8 implementation in C, but I am unable to figure out for polynomial(x8,x5,x4,1) i.e. 0x31 and initialization 0xFF.
Also reflect input = False, reflect output = False and final XOR = 0x00.
I tried several…

arnab dasgupta
- 219
- 2
- 3
- 9
8
votes
1 answer
How well do Non-cryptographic hashes detect errors in data vs. CRC-32 etc.?
Non-cryptographic hashes such as MurmurHash3 and xxHash are almost exclusively designed for hash tables, but they appear to function comparably (and even favorably) to CRC-32, Adler-32 and Fletcher-32. Non-crypto hashes are often faster than CRC-32…

bryc
- 12,710
- 6
- 41
- 61
8
votes
1 answer
On this Kmett CRC article, why does ab = a0^n + 0^m b? What does this notation mean?
In Edward Kmett's article on CRCs it has the following derivation:
CRC(ab) = -- definition of CRC
crc(INIT,ab) + FINAL = -- linearity
crc(INIT,a0^n + 0^m b) + FINAL = -- additive…

rityzmon
- 1,945
- 16
- 26