CRC-32C (Castagnoli) for C++ and .NET

C++ tutorial

After downloading the library, your first step is to include the header:

#include "crc32c.h"

After that, you will get access to the following function:

/*
    Computes CRC-32C (Castagnoli) checksum. Uses Intel's CRC32
    instruction if it is available. Otherwise it uses a very
    fast software fallback.
*/
extern "C" uint32_t crc32c_append(
    uint32_t crc,               // Initial CRC value. Typically it's 0.
                                // You can supply non-trivial initial
                                // value here. Initial value can be used
                                // to chain CRC from multiple buffers.
    const uint8_t *input,       // Data to be put through the CRC
                                // algorithm.
    size_t length);             // Length of the data in the input
                                // buffer.

You can call the function like this:

uint32_t crc = crc32c_append(0, input, 10000);

As the comments in above declaration suggest, you can compute crc from multiple chained buffers:

uint32_t intermediate = crc32c_append(0, input, 3000);
uint32_t crc = crc32c_append(intermediate, input + 3000, 7000);

And that's it. You can add any pre/post-processing of the CRC value if your application requires it. Enjoy!

Project CRC-32C for C++ and .NET
Version 1.0.5
CRC type CRC-32C (Castagnoli)
Polynomial 0x1EDC6F41 / 0x82F63B78
CRC features configurable initial value, chainable, no pre/post-processing, continuous bit order
Optimizations Intel CRC32 instruction (x3) in hardware
Sliced table-driven software fallback
Performance 20 GB/s in hardware
2 GB/s in software
NuGet Crc32C (C++), Crc32C.NET (.NET)
Download crc32c-hw-1.0.5.7z (C++ and .NET)
Source code crc32c-hw and Crc32C.NET on Bitbucket
License BSD license, zlib license
Credits Robert Važan, Mark Adler