This is one the boost framework I had already started using a few times in the past. A good CRC generator is often handy, and I figured if boost is providing one, why look somewhere else?
I won’t go in much details as it is quite a straightforward system. You simply define a CRC accumulator of the size and features you want, then you simply feed it with data.
Here’s a simple example to generate a 32-bits CRC from a string:
#include <boost/crc.hpp> ... const string kTest1("Hello World!!!\n"); const string kTest2("This is a second string..."); boost::crc_32_type result; result.process_bytes( kTest1.c_str(), kTest1.length() ); cout << "After one string: " << result.checksum() << endl; result.process_bytes( kTest2.c_str(), kTest2.length() ); cout << "After two string: " << result.checksum() << endl;