0是循环冗余校验(CRC)的可能校验和吗?
我使用boost来计算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?发布于 2011-04-30 02:25:49
是。接收任何消息,CRC,并计算其x,crc(x)。则crc(x . crc(x))将为0(其中.表示连接)。
事实上,此关系可用于验证消息+ CRC是否已正确传输(例如,请参阅http://en.wikipedia.org/wiki/Computation_of_CRC上的第二个动画图)。
https://stackoverflow.com/questions/5835777
复制相似问题