数据长度与CRC长度 [英] Data Length vs CRC Length
问题描述
我见过8位,16位和32位CRC。
I've seen 8-bit, 16-bit, and 32-bit CRCs.
我需要在什么时候跳到更宽的范围? CRC?
我的直觉是它基于数据长度:
My gut reaction is that it is based on the data length:
- 1-100字节:8位CRC
- 101-1000字节:16位CRC
- 1001-?? ?字节:32位CRC
编辑:
在Wikipedia页面上了解CRC和Lott的答案,这是我们有:
Looking at the Wikipedia page about CRC and Lott's answer, here' what we have:
<64字节:8位CRC
<64 bytes: 8-bit CRC
<16K字节:16位CRC
<16K bytes: 16-bit CRC
<512M字节:32位CRC
<512M bytes: 32-bit CRC
推荐答案
不是研究主题。确实很容易理解: http://en.wikipedia.org/wiki/Cyclic_redundancy_check
It's not a research topic. It's really well understood: http://en.wikipedia.org/wiki/Cyclic_redundancy_check
数学非常简单。 8位CRC将所有消息精简为256个值之一。如果您的消息长度超过几个字节,则具有相同哈希值的多条消息的可能性就会越来越高。
The math is pretty simple. An 8-bit CRC boils all messages down to one of 256 values. If your message is more than a few bytes long, the possibility of multiple messages having the same hash value goes up higher and higher.
16位CRC,类似地,为您提供65,536个可用哈希值之一。任何两个具有这些值之一的消息的几率是多少?
A 16-bit CRC, similarly, gives you one of the 65,536 available hash values. What are the odds of any two messages having one of these values?
32位CRC可为您提供约40亿个可用哈希值。
A 32-bit CRC gives you about 4 billion available hash values.
摘自Wikipedia文章:最大总块长等于 2 ** r − 1
。以位为单位。您无需做太多研究就可以看到 2 ** 9-1
是511位。使用CRC-8,长度超过64个字节的多条消息将具有相同的CRC校验和值。
From the wikipedia article: "maximal total blocklength is equal to 2**r − 1
". That's in bits. You don't need to do much research to see that 2**9 - 1
is 511 bits. Using CRC-8, multiple messages longer than 64 bytes will have the same CRC checksum value.
这篇关于数据长度与CRC长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!