Boost logo

Boost Users :

From: Norbert Unterberg (nunterberg_at_[hidden])
Date: 2007-11-06 04:12:34


Some CRC algorithms (when using 0xFFFF as an initial value and final
XOR) have a nice property that then checking the consistency of a data
block that has a CRC checksum appended, the resulting checksum value is
a constant.

Is there an easy way to extract this constant value from boost::crc
directly?

Example: We use a CRC like this:

typedef
boost::crc_optimal<16, 0x1021, 0xFFFF, 0xFFFF, true, true> crc_type;

When sending a block of data, we append the generated CRC. The receiver
side feeds the complete block incluing the CRC bytes into its generator.
When the data block has no errors, the crc.checksum() is always exactly
0x0F47. Currently, I manually calculate that constant by something like
this:
        crc_type crc;
        crc_type::value_type val(0);
        crc.process_bytes(&val, sizeof(val));
        m_key = crc.checksum();

Is there an easier way to extract this "crc is correct" value?

Norbert


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net