Question

Is it possible to determine the byte, or bytes, that have changed from a CRC16 calculation?

For example, say I get a config file that is 780 bytes that includes the CRC16 as a two byte value at the end (so the CRC16 is calculated based on the first 778 bytes). When I calculate the CRC16 for the file contents (the 778 bytes that do not include the CRC16 at the end) and it is different, can I determine the byte offset the error occurred at?

Was it helpful?

Solution

The short answer is NO, you can't.

To understand why you have to understand how the CRC is computed and that mathematically that is called a hashing operation. What it means is the the output can not be reconstructed reliably from the generated hash code (in this case the CRC).

There are statistical analysis methods that may allow you to infer some information about the original text based on certain specific input test cases but in the majority of cases, and to a naive observer there's not direct mapping back to the original text from the CRC. So unless the original text was constructed in a certain way there's no way to know the offset at which data was changed in most cases.

OTHER TIPS

Using just the two computations of the CRC16, no.

CRC16 is just a checksum: it can tell you that there is a difference, but not where.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top