Home > Frameworks > boost::CRC


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;


Categories: Frameworks
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: