Questions tagged [crc]

Cyclic redundancy check. An error checking mechanism used for verifying data integrity in serial protocols.

1120 questions
147
votes
14 answers

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?
Gili
  • 86,244
  • 97
  • 390
  • 689
91
votes
15 answers

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 sure that the file on both sides are equal
eflles
  • 6,606
  • 11
  • 41
  • 55
62
votes
2 answers

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, store this and compute the same checksum a little…
Julien Genestoux
  • 31,046
  • 20
  • 66
  • 93
59
votes
7 answers

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. I've created a function to calculate a CRC16…
Jonathan Lamothe
  • 713
  • 1
  • 6
  • 5
57
votes
2 answers

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.: My string field is unique in the database. If…
nguyenngoc101
  • 1,211
  • 4
  • 16
  • 28
49
votes
7 answers

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 1001 - ??? bytes: 32-bit CRC EDIT: Looking at the…
Robert Deml
  • 12,390
  • 20
  • 65
  • 92
42
votes
5 answers

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 something like: int GetCrc32(const string&…
Andreas Bonini
  • 44,018
  • 30
  • 122
  • 156
35
votes
10 answers

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.readlines() fd.close() for eachLine in…
user203547
  • 383
  • 1
  • 3
  • 4
31
votes
1 answer

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.
Jeyavel
  • 2,974
  • 10
  • 38
  • 48
25
votes
3 answers

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 standard that would explicitly prevent this from…
dtoux
  • 1,754
  • 3
  • 21
  • 38
25
votes
2 answers

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 skills out there who might be able to crack this…
MSunstrum
  • 251
  • 3
  • 5
23
votes
4 answers

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 a good CRC implementation somebody can vouch for,…
oyvind
  • 1,429
  • 3
  • 14
  • 24
22
votes
2 answers

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 0xC061, however the C# method that generates CRC-16…
dynamicuser
  • 1,522
  • 3
  • 24
  • 52
21
votes
2 answers

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 (0xFFFF starting, 0x1021 mask) for the entire…
mblem22
  • 313
  • 2
  • 5
19
votes
4 answers

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 packet's payload totally changes the checksum, so I…
dpavlin
  • 1,372
  • 2
  • 9
  • 18
1
2 3
74 75