Questions tagged [crc32]

A cyclic redundancy check (CRC) is an error-detecting code designed to detect accidental changes to raw computer data, and is commonly used in digital networks. (wiki) A CRC32 algorithm typically takes in a file stream or character array and calculates an unsigned long codeword from the input. One can transmit this codeword and re-calculate it on the receiver end, then compare it to the transmitted one to detect an error.

A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data. Blocks of data entering these systems get a short check value attached, based on the remainder of a polynomial division of their contents; on retrieval the calculation is repeated, and corrective action can be taken against presumed data corruption if the check values do not match. wikipedia

The most commonly used polynomial lengths are:

  • CRC-8: 9 bits
  • CRC-16: 17 bits
  • CRC-32: 33 bits
  • CRC-64: 65 bits

A truly excellent tutorial on CRC's is Ross Williams' "Painless Guide to CRC Detection Algorithms", which can also be found here, here, here, here, and here.

570 questions
5
votes
2 answers

32-bit checksum algorithm better quality than CRC32?

Are there any 32-bit checksum algorithm with either: Smaller hash collision probability for input data sizes < 1 KB ? Collision hits with more uniform distribution. These relative to CRC32. I'm practically not counting on first property, because…
Agnius Vasiliauskas
  • 10,935
  • 5
  • 50
  • 70
5
votes
1 answer

index on url or hashing considering RAM

I am working on a project which needs to add/update around 1 million urls daily. Some days are mostly updates and some days are mostly add and some days are mix. So, on every query there is need to look up uniqueness of url in url table. How look…
Rick James
  • 307
  • 1
  • 9
5
votes
1 answer

How to calculate SFV-style CRC32 in Linux commandline?

Is there an equivalent to md5sum/sha1sum in Linux for calculating SFV-style CRC32s? I checked out cksum, but it seems to be calculating a different sum (perhaps a different polynomial? or I'm interpreting cksum's output wrong). Preferably not…
Henry Tung
  • 51
  • 1
  • 4
5
votes
3 answers

Understanding Cyclic Redundancy Code algorithm for beginners

at section 5.5 of the PNG Specification, it discusses this concept in the PNG file format called "CRC" or "Cyclic Redundancy Code". I've never heard of it before, so I'm trying to understand it. The CRC polynomial employed is x32 + x26 + x23 + x22…
5
votes
1 answer

Why LevelDB and RocksDB need a `masked CRC32`

From the crc32.h of leveldb or rocksdb, we can find a comment saying: static const uint32_t kMaskDelta = 0xa282ead8ul; // Return a masked representation of crc. // // Motivation: it is problematic to compute the CRC of a string that // contains…
Myrfy
  • 575
  • 4
  • 11
5
votes
2 answers

Most efficent way to calculate CRC64 with reflected input

I need to calculate a CRC-64 using this setup into this wonderful website: http://www.sunshine2k.de/coding/javascript/crc/crc_js.html As you can see I require "input reflected" and that means that I need to reverse the bit order of any byte (a bit…
5
votes
2 answers

I know the length and restricted character set of some CRC32 hashes. Does this make it easier to reverse them?

We have a bunch of CRC32 hashes which would be really nice to know the input of. Some of them are short enough that brute-forcing them is feasible; others are not. The CRC32 algorithm being used is equal to the one in Python's binascii (its…
Toomai
  • 3,974
  • 1
  • 20
  • 22
5
votes
3 answers

How to detect crc32 on aarch64

Is it possible for a user program on aarch64 detect whether crc32 instructions are available? I have found references to kernel support for such detection, implying that the registers with the information about what instructions will work in user…
Mark Adler
  • 101,978
  • 13
  • 118
  • 158
5
votes
3 answers

How can I speed up crc32 calculation?

I'm trying to write a crc32 implementation on linux that's as fast as possible, as an exercise in learning to optimise C. I've tried my best, but I haven't been able to find many good resources online. I'm not even sure if my buffer size is…
sockmeistr
  • 53
  • 4
5
votes
1 answer

How to use crc32 from zlib in swift (Xcode 9)

I'm new to swift/xcode and am trying to use the crc32 function that, as mentioned here, is provided in zlib from libz.dylib . I've modified the code so that I am now trying: let message1 = "some message".first?.value!.data(using:…
Mikmac
  • 85
  • 2
  • 8
5
votes
3 answers

CRC32 calculation with CRC hash at the beginning of the message in C

I need to calculate CRC of the message and put it at the beginning of this message, so that the final CRC of the message with 'prepended' patch bytes equals 0. I was able to do this very easily with the help of few articles, but not for my specific…
LStarling
  • 93
  • 1
  • 7
5
votes
1 answer

Crc32 C implementation - doesn't work

I found this CRC32 implementation on the internet, little bit changed it, but I can't get it to work. I initialize it and update it on every byte I get from input, but the hash I get is not what it should be... typedef struct { unsigned short…
kiro135
  • 53
  • 4
5
votes
3 answers

How to find crc32 of big files?

The PHP's crc32 support string as input.And For a file , below code will work OFC. crc32(file_get_contents("myfile.CSV")); But if file goes huge (2 GB) it might raise out of memory Fatal error. So any way around to find checksum of huge files ?
Arshdeep
  • 4,281
  • 7
  • 31
  • 46
5
votes
1 answer

How to calculate the CRC of an arrayBuffer (From FileReader in javascript) compatible with the CRC32 function in php?

On the client side (Javascript) I'm using the FileReader() Object to read a local file from a browser and this file is sent to the server (PHP) thanks to the XMLHttpRequest() object. The object I recover thanks to the FileReader object is an…
monstergold
  • 755
  • 1
  • 9
  • 24
5
votes
1 answer

PHP CRC32 length output

Is there anything that can make the returned length of the PHP CRC32 function to vary? Thanks!
Industrial
  • 41,400
  • 69
  • 194
  • 289