【发布时间】:2012-07-24 01:17:33
【问题描述】:
我有一个二进制字符串(如下面的十六进制所示)并且正在使用 CRC-16-CCITT。我希望我所有的 CRC 都达到一个设定值 0x1D0F。我知道可以通过将 2 个字节附加到原始消息的末尾来使 CRC 匹配此值,但我不确定如何找出附加值需要是什么。
例如。
0x01 0000 0000 0000 0000 0000 0000 0000 0000 13D8
附加值为0x13D8
通过将此 13D8 添加到消息中,CRC 为我提供了所需的 0x1D0F。
任何有关如何计算此 0x13D8 值的帮助将不胜感激。
如果它可以在代码中巧妙地完成,那将是一个奖励!
【问题讨论】:
-
如果你想不出来,至少你最多只需要尝试 2^16 个值就可以得到正确的值。
-
维基百科的CRC文章链接到Reversing CRC – Theory and Practice,说
The presented methods offer a very easy and efficient way to modify your data so that it will compute to a CRC you want or at least know in advance. This is not a very difficult task, as CRC is not a cryptographical hash algorithm [...] So you should never consider the CRC as some kind of message authentication code [...] – it can easily be forged. -
为什么需要一个固定的 CRC 值?只是好奇这里的用例是什么,似乎你正在做一些比它需要的更复杂的事情。这是一个家庭作业吗?
标签: binary embedded checksum crc error-detection