简体   繁体   English

通过CRC16确定错误偏移字节

[英]Determine Error Offset Byte by CRC16

Is it possible to determine the byte, or bytes, that have changed from a CRC16 calculation? 是否可以确定从CRC16计算中更改的一个或多个字节?

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). 例如,假设我得到一个780字节的配置文件,该文件的末尾包括两个字节的CRC16值(因此,CRC16是根据前778个字节计算得出的)。 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? 当我计算文件内容的CRC16(778个字节的末尾不包括CRC16)时,是否有所不同,是否可以确定错误发生的字节偏移?

Using just the two computations of the CRC16, no. 仅使用CRC16的两次计算即可。

CRC16 is just a checksum: it can tell you that there is a difference, but not where. CRC16只是一个校验和:它可以告诉您有区别,但没有区别。

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. 要了解为什么必须了解CRC的计算方式以及在数学上称为哈希运算的原因。 What it means is the the output can not be reconstructed reliably from the generated hash code (in this case the CRC). 这意味着无法从生成的哈希码(在这种情况下为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. 有一些统计分析方法可以使您根据某些特定的输入测试用例来推断一些有关原始文本的信息,但是在大多数情况下,对于天真的观察者来说,并不能直接从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. 因此,除非以某种方式构造了原始文本,否则在大多数情况下都无法知道更改数据的偏移量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM