2011-04-29 87 views
1

0是循环冗余校验(CRC)的可能校验和吗?CRC计算输出

我使用升压来计算CRC:

const unsigned int CrcPolynomial = 0x11021; 
const unsigned short InitialValue = 0xffff; 
boost::crc_optimal<16, CrcPolynomial, InitialValue, 0, true, true> Crc; 
// process some bytes... 
int x = Crc.checksum(); // <------ can this be 0? 

回答

3

是。请采取任何消息,x,并计算其CRC,crc(x)。那么crc(x . crc(x))将为0(其中.表示串联)。实际上,这种关系可以用来验证消息+ CRC是否已被正确传输(例如参见http://en.wikipedia.org/wiki/Computation_of_CRC的第二个动画图)。

+0

“然后crc(x。crc(x))将为0”。这仅适用于基本的CRC算法,不能否定位或反转位。有关更多详细信息,请参阅此帖:http://stackoverflow.com/questions/5112733/checking-crc32-of-zero-padded-bitstream/6672972#6672972 – Nayuki 2011-07-15 20:09:49