BDE 4.14.0 Production release
|
Provide utilities to calculate the CRC32-C checksum of a dataset.
This component defines a struct, bdlde::Crc32c
that dramatically accelerates (as opposite to the bdlde::Crc32
component) calculation of a CRC32-C checksum (a cyclic redundancy check, comprised of 32 bits, that uses the Castagnoli polynomial), using a hardware-accelerated implementation if supported or a software implementation otherwise. It additionally defines the struct bdlde::Crc32c_Impl
to expose alternative implementations that should not be used other than to test and benchmark. Note that a CRC32-C checksum is a strong and fast technique for determining whether or not a message was received without errors. Also note that a CRC-32 checksum does not aid in error correction and is not naively useful in any sort of cryptography application.
Thread safe.
Hardware-accelerated implementation is enabled at compile time when building on a supported architecture with a compatible compiler. In addition, runtime checks are performed to detect whether the running platform has the required hardware support:
is_sparc_crc32c_avail
system callSee the test driver for this component in the .t.cpp
to compare performance of the hardware-accelerated and software implementations against various alternative implementations that compute a 32-bit CRC checksum.
This section illustrates intended use of this component.
The following code illustrates how to calculate and update a CRC32-C checksum for a message over the course of building the full message.
First, prepare a message.
Now, generate a checksum for message
.
Finally, if we learn that our message has grown by another chunk and we want to compute the checksum of the original message plus the new chunk, let's update the checksum by using it as a starting point.