【问题标题】:CRC calculation outputCRC计算输出
【发布时间】:2011-04-29 18:20:06
【问题描述】:

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?

【问题讨论】:

    标签: c++ boost crc


    【解决方案1】:

    是的。获取任何消息,x,并计算其 CRC,crc(x)。那么crc(x . crc(x)) 将为0(其中. 表示连接)。

    事实上,这种关系可用于验证消息 + CRC 是否已正确传输(例如参见http://en.wikipedia.org/wiki/Computation_of_CRC 的第二个动画图)。

    【讨论】:

    猜你喜欢
    • 2017-03-01
    • 2011-11-08
    • 2021-08-09
    • 1970-01-01
    • 2019-09-27
    • 2017-02-11
    • 2014-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多