Standard C++ Libaray

This library contains standard C++ code, and is dependant on nothing other than the standard C/C++ library. Where posible I like to implement my common tools and utility code within the CyTools namespace.

#include <iostrem>       // std::cout
#include <iomanip>       // std::setfill, std::setw...
#include <string>        // std::string
#include <cstring>       // std::strncpy
#include <CyCrc.hpp>     // CyTools::crc32

int main(int argc, char* argv[]) {
  int data_a = 0x7590b31a;
  float data_b = 2.538f;
  char data_c[10];
  std::string data_d = "String 1";

  std::strncpy(data_c, "String 2", sizeof(data_c));

  CyTools::crc32 a_crc;  // creates a crc using the default 32-bit standard (PK-Zip)
                         // construction with default constructor enables JIT table

  a_crc.add(data_a);     // Uses sizeof and adds data_a
  a_crc.add(data_b);     // Uses sizeof and adds data_b
  a_crc.add(data_c);     // Uses std::char_traits<char>::length, adds 8 characters
  a_crc.add(data_c, sizeof(data_c));  // adds all charaters of data_c, including nulls
  a_crc.add(data_d);     // not binary safe, but has overload, adds 8 characters

  std::cout << std::setfill('0') << std::setw(8) << std::right << std::hex;
  std::cout << a_crc << std::endl;    // auto-finalization for seemless cast & stream

  return 0;
}

CyCrc

version - 1.0.3

A small, fast, single header, CRC engine. Working with or without tables. When used, tables can be compile-time or run-time calculated. Tables can also be left to the CRC engine to manage, in this case tables are created just-in-time. The main header defines CRC standards for 8, 16, 32, and 64-bit CRC's. A second header (optional) defines a number of other standards.

Downloads

CyCrc.zip Main CRC header only.
CyCrc-complete.zip CRC and extra definitions headers.
CyCrc-examples.zip Sample code showing usage of CyCrc.