Questions tagged [crc]
Cyclic redundancy check. An error checking mechanism used for verifying data integrity in serial protocols.
1,138
questions
150
votes
14
answers
117k
views
When is CRC more appropriate to use than MD5/SHA1?
When is it appropriate to use CRC for error detection versus more modern hashing functions such as MD5 or SHA1? Is the former easier to implement on embedded hardware?
95
votes
15
answers
99k
views
What is the fastest hash algorithm to check if two files are equal?
What is the fastest way to create a hash function which will be used to check if two files are equal?
Security is not very important.
Edit: I am sending a file over a network connection, and will be ...
63
votes
2
answers
50k
views
What checksum algorithm should I use?
I'm building a system which needs to be able to find if blobs of bytes have been updated.
Rather than storing the whole blob (they can be up to 5MBs), I'm thinking I should compute a checksum of it, ...
60
votes
7
answers
280k
views
Function to Calculate a CRC16 Checksum
I'm working on a library to provide simple reliable communication over an RS232 or RS485 connection. Part of this code involves using a CRC16 checksum on the data to detect corruption from line noise....
57
votes
2
answers
59k
views
Probability of collision when using a 32-bit hash
I have a 10-character string key field in a database. I've used CRC32 to hash this field, but I'm worrying about duplicates. Could somebody show me the probability of collision in this situation?
P.S.:...
51
votes
7
answers
95k
views
Data Length vs CRC Length
I've seen 8-bit, 16-bit, and 32-bit CRCs.
At what point do I need to jump to a wider CRC?
My gut reaction is that it is based on the data length:
1-100 bytes: 8-bit CRC
101 - 1000 bytes: 16-bit CRC
...
43
votes
5
answers
32k
views
How to use boost::crc?
I want to use boost::crc so that it works exactly like PHP's crc32() function. I tried reading the horrible documentation and many headaches later I haven't made any progress.
Apparently I have to do ...
35
votes
10
answers
57k
views
compute crc of file in python
I want to calculate the CRC of file and get output like: E45A12AC. Here's my code:
#!/usr/bin/env python
import os, sys
import zlib
def crc(fileName):
fd = open(fileName,"rb")
content = fd....
33
votes
1
answer
13k
views
How to calculate 32 bit CRC in Ruby on rails?
I want to calculate 32 bit CRC value for 'input field value" in Ruby on rails.
need the sample code , please help me anyone.
25
votes
3
answers
19k
views
Can CRC32(C) ever return to 0?
I'm wondering if CRC32 sum and CRC32C in particular ever return to 0? The simple answer would be "yes" given a large enough data set. However, I was wondering if there is any provisioning in CRC32C ...
25
votes
2
answers
3k
views
Trying to reverse engineer a packet checksum/CRC/hash
I have an old, no longer manufactured electronic device with a serial port. I am trying to reverse engineer the data packet CRC/checksum/hash used in this device.
Anyone with keen eyes, sharp math ...
23
votes
4
answers
59k
views
definitive CRC for C
Since CRC is so widely used, I'm surprised by having a hard time finding CRC implementations in C.
Is there a "definitive" CRC calculation snippet/algorithm for C, that "everyone" uses? Or: is there ...
22
votes
2
answers
83k
views
How to generate a CRC-16 from C#
I am trying to generate a CRC-16 using C#. The hardware I am using for RS232 requires the input string to be HEX. The screenshot below shows the correct conversion, For a test, I need 8000 to be ...
21
votes
2
answers
8k
views
CRC Calculation Of A Mostly Static Data Stream
Background:
I have a section of memory, 1024 bytes. The last 1020 bytes will always be the same. The first 4 bytes will change (serial number of a product). I need to calculate the CRC-16 CCITT (...
19
votes
4
answers
19k
views
How could I guess a checksum algorithm?
Let's assume that I have some packets with a 16-bit checksum at the end. I would like to guess which checksum algorithm is used.
For a start, from dump data I can see that one byte change in the ...
18
votes
7
answers
37k
views
CRC32 Collision
I am trying to find a collision between two messages that will lead to the same CRC hash.
Considering I am using CRC32, is there any way I can shorten the list of possible messages I have to try when ...
18
votes
2
answers
13k
views
Get CRC checksum of an NSData in Objective-C
How can I count CRC (32 or 64) of an NSData object in Objective-C?
Thanks in advance!
18
votes
4
answers
44k
views
Reversing CRC32
I'm looking for a way to reverse a CRC32 checksum. There are solutions around, but they are either badly written, extremely technical and/or in Assembly. Assembly is (currently) beyond my ken, so I'm ...
18
votes
2
answers
34k
views
Fast CRC algorithm?
I want to create a 32-bit number out of an ASCII-string. CRC32 algorithm is exactly what I'm looking for, but I can't use it because the table it requires is way too huge (it is for an embedded system ...
18
votes
1
answer
18k
views
What is cyclic redundancy check and how it works in simple terms (for-dummies style)?
I'm having trouble understanding the concept and workings of the ugly sounding term "cyclic redundancy check". I'm attending a college course on Computer Networks and I'm getting lost already.
The ...
18
votes
4
answers
17k
views
Is it possible to do rudimentary error correction with CRC?
I know the whole intention of using CRC is to do error detection, but I heard someone state that it can be used to do basic error correction in addition to error detection. I was curious if this was ...
18
votes
2
answers
13k
views
Is there a C#/.NET standard implementation of CRC?
I know that implementations exist for SHA-1 and SHA-256 in System.Security.Cryptography.
Is there anything built in that can compute CRC hashes?
17
votes
1
answer
15k
views
How is PNG CRC calculated exactly?
For the past 4 hours I've been studying the CRC algorithm. I'm pretty sure I got the hang of it already.
I'm trying to write a png encoder, and I don't wish to use external libraries for the CRC ...
15
votes
5
answers
49k
views
C# CRC implementation
I am trying to integrate a Serial-port device into my application, which needs CRC-CCTT validation for the bytes that I send to it.
I'm kinda new into managing byte packets, and need help for this.
...
13
votes
1
answer
11k
views
Storing CRC into an AXF/ELF file
I'm currently working on a C program in the LPCXpresso (eclipse-based) tool-chain on Windows 7, an IDE with gcc targeting the an NXP Cortex M3 microprocessor. It provides a simple way to compile-link-...
12
votes
2
answers
9k
views
How to get CRC64 distributed calculation (use its linearity property)?
I need hash over pretty large files which is stored on distributed FS. I'm able to process parts of file with much more better performance than whole file so I'd like to be able to calculate hash over ...
12
votes
3
answers
8k
views
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. ...
12
votes
1
answer
915
views
Basic CRC32 Wikipedia implementation differs from standard CRC32 seen online
I have a basic CRC32 implementation following Wikipedia's Code Fragment:1 sample. I think I have done it right, with the modification of using an n-bit register for the remainderPolynomial instead of ...
11
votes
4
answers
20k
views
CRC16 checksum: HCS08 vs. Kermit vs. XMODEM
I'm trying to add CRC16 error detection to a Motorola HCS08 microcontroller application. My checksums don't match, though. One online CRC calculator provides both the result I see in my PC program and ...
11
votes
5
answers
2k
views
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 ...
11
votes
1
answer
6k
views
Finding which Checksum is used
Together with some other people we are trying to make a Savegameeditor for a game, but we came accross some problems.
The savegame files contain a kind of checksum,of which we can't seem to find which ...
11
votes
3
answers
7k
views
Calculate/validate bz2 (bzip2) CRC32 in Python
I'm trying to calculate/validate the CRC32 checksums for compressed bzip2 archives.
.magic:16 = 'BZ' signature/magic number
.version:8 = 'h' for Bzip2 ('H'...
10
votes
8
answers
42k
views
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 ...
10
votes
3
answers
27k
views
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, ...
10
votes
2
answers
18k
views
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 ...
10
votes
4
answers
1k
views
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 ...
10
votes
1
answer
591
views
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 ...
9
votes
5
answers
79k
views
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 ...
9
votes
2
answers
11k
views
_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 ...
9
votes
2
answers
8k
views
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 ...
9
votes
1
answer
23k
views
What is the hamming distance, and how do I determine it for a CRC scheme?
While studying for a class in computer networks, the prof talked about the hamming distance between 2 valid code words in a sample code. I have read about hamming distance, and it makes sense from the ...
9
votes
3
answers
11k
views
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 <--- ...
8
votes
5
answers
63k
views
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 ...
8
votes
1
answer
22k
views
Convert C CRC16 to Java CRC16
I am currently working on a project, having an embedded system sending data to a PC via radio. The packets get a crc16 checksum at the end and it's calculated based on this algorithm:
uint16_t crc16 (...
8
votes
7
answers
4k
views
CRC checks for files
I'm working with a small FAT16 filesystem, and I want to generate CRC values for indidual XML files which store configuration information. In case the data changes or is corrupted, I want to be able ...
8
votes
2
answers
20k
views
Expected collisions for perfect 32bit crc
I'm trying to determine how my crc compares to an "ideal" 32bit crc.
So I ran my crc over 1 million completely random samples of data and collected the amount of collisions, I want to compare this ...
8
votes
1
answer
162
views
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^...
8
votes
3
answers
5k
views
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 ?
8
votes
1
answer
1k
views
A few questions about CRC basics
I am an electronic engineer and have not found it important to consider CRC from a purely mathematical perspective. However, I have the following questions:
Why do we add n zeros to the message when ...
8
votes
1
answer
2k
views
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....