Which CRC-32 algorithm is used in the Java CRC-32 class ? The java doc does not give any details. What is the polynomail used and the initial value for calculaton ?
public class CRC32 extends Object implements Checksum. A class that can be used to compute the CRC-32 of a data stream. Passing a null argument to a method in this class will cause a NullPointerException to be thrown.
The ASCII and Binary OEM7 family and SMART2 message formats all contain a 32-bit CRC for data verification. This allows the user to ensure the data received (or transmitted) is valid with a high level of certainty. The C functions below may be implemented to generate the CRC of a block of data.
Save this answer. Show activity on this post. If you want to check if two files are the same, CRC32 checksum is the way to go because it's faster than MD5. But be careful: CRC only reliably tells you if the binaries are different; it doesn't tell you if they're identical.
CRC-32 is a indicated in the package docs for java.util.zip to be specified in RFC 1952. RFC 1952 defines CRC32 as specified in ISO 3309 which I could not find a free copy of to link you to. However RFC 1952 also indicates that section 8.1.1.6.2 of ITU-T recommendation V.42 specifies the same implementation.
In partcular the polynomial being used is
x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
According to the source:
Computes CRC32 data checksum of a data stream. The actual CRC32 algorithm is described in RFC 1952 (GZIP file format specification version 4.3). Can be used to get the CRC32 over a stream if used with checked input/output streams.
The RFC1952 can be found here, but presents a quite technical read.
The initial value for the CRC is 0xFFFFFFFF
, and the CRC table is built the first time the class is loaded on the VM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With