CRC++ 1.0.1.0
Easy to use and fast C++ CRC library.
|
Static class for computing CRCs. More...
#include <CRC.h>
Classes | |
struct | Parameters |
CRC parameters. More... | |
struct | Table |
CRC lookup table. After construction, the CRC parameters are fixed. More... | |
Public Member Functions | |
CRC ()=delete | |
CRC (const CRC &other)=delete | |
CRC & | operator= (const CRC &other)=delete |
CRC (CRC &&other)=delete | |
CRC & | operator= (CRC &&other)=delete |
Static Public Member Functions | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | Calculate (const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters) |
Computes a CRC. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | Calculate (const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters, CRCType crc) |
Appends additional data to a previous CRC calculation. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | Calculate (const void *data, crcpp_size size, const Table< CRCType, CRCWidth > &lookupTable) |
Computes a CRC via a lookup table. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | Calculate (const void *data, crcpp_size size, const Table< CRCType, CRCWidth > &lookupTable, CRCType crc) |
Appends additional data to a previous CRC calculation using a lookup table. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | CalculateBits (const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters) |
Computes a CRC. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | CalculateBits (const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters, CRCType crc) |
Appends additional data to a previous CRC calculation. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | CalculateBits (const void *data, crcpp_size size, const Table< CRCType, CRCWidth > &lookupTable) |
Computes a CRC via a lookup table. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | CalculateBits (const void *data, crcpp_size size, const Table< CRCType, CRCWidth > &lookupTable, CRCType crc) |
Appends additional data to a previous CRC calculation using a lookup table. | |
static const Parameters< crcpp_uint8, 4 > & | CRC_4_ITU () |
Returns a set of parameters for CRC-4 ITU. | |
static const Parameters< crcpp_uint8, 5 > & | CRC_5_EPC () |
Returns a set of parameters for CRC-5 EPC. | |
static const Parameters< crcpp_uint8, 5 > & | CRC_5_ITU () |
Returns a set of parameters for CRC-5 ITU. | |
static const Parameters< crcpp_uint8, 5 > & | CRC_5_USB () |
Returns a set of parameters for CRC-5 USB. | |
static const Parameters< crcpp_uint8, 6 > & | CRC_6_CDMA2000A () |
Returns a set of parameters for CRC-6 CDMA2000-A. | |
static const Parameters< crcpp_uint8, 6 > & | CRC_6_CDMA2000B () |
Returns a set of parameters for CRC-6 CDMA2000-B. | |
static const Parameters< crcpp_uint8, 6 > & | CRC_6_ITU () |
Returns a set of parameters for CRC-6 ITU. | |
static const Parameters< crcpp_uint8, 6 > & | CRC_6_NR () |
Returns a set of parameters for CRC-6 NR. | |
static const Parameters< crcpp_uint8, 7 > & | CRC_7 () |
Returns a set of parameters for CRC-7 JEDEC. | |
static const Parameters< crcpp_uint8, 8 > & | CRC_8 () |
Returns a set of parameters for CRC-8 SMBus. | |
static const Parameters< crcpp_uint8, 8 > & | CRC_8_EBU () |
Returns a set of parameters for CRC-8 EBU (aka CRC-8 AES). | |
static const Parameters< crcpp_uint8, 8 > & | CRC_8_HDLC () |
Returns a set of parameters for CRC-8 HDLC (ISO/IEC 13239:2002). | |
static const Parameters< crcpp_uint8, 8 > & | CRC_8_MAXIM () |
Returns a set of parameters for CRC-8 MAXIM (aka CRC-8 DOW-CRC). | |
static const Parameters< crcpp_uint8, 8 > & | CRC_8_WCDMA () |
Returns a set of parameters for CRC-8 WCDMA. | |
static const Parameters< crcpp_uint8, 8 > & | CRC_8_LTE () |
Returns a set of parameters for CRC-8 LTE. | |
static const Parameters< crcpp_uint16, 10 > & | CRC_10 () |
Returns a set of parameters for CRC-10 ITU. | |
static const Parameters< crcpp_uint16, 10 > & | CRC_10_CDMA2000 () |
Returns a set of parameters for CRC-10 CDMA2000. | |
static const Parameters< crcpp_uint16, 11 > & | CRC_11 () |
Returns a set of parameters for CRC-11 FlexRay. | |
static const Parameters< crcpp_uint16, 11 > & | CRC_11_NR () |
Returns a set of parameters for CRC-11 NR. | |
static const Parameters< crcpp_uint16, 12 > & | CRC_12_CDMA2000 () |
Returns a set of parameters for CRC-12 CDMA2000. | |
static const Parameters< crcpp_uint16, 12 > & | CRC_12_DECT () |
Returns a set of parameters for CRC-12 DECT (aka CRC-12 X-CRC). | |
static const Parameters< crcpp_uint16, 12 > & | CRC_12_UMTS () |
Returns a set of parameters for CRC-12 UMTS (aka CRC-12 3GPP). | |
static const Parameters< crcpp_uint16, 13 > & | CRC_13_BBC () |
Returns a set of parameters for CRC-13 BBC. | |
static const Parameters< crcpp_uint16, 15 > & | CRC_15 () |
Returns a set of parameters for CRC-15 CAN. | |
static const Parameters< crcpp_uint16, 15 > & | CRC_15_MPT1327 () |
Returns a set of parameters for CRC-15 MPT1327. | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_ARC () |
Returns a set of parameters for CRC-16 ARC (aka CRC-16 IBM, CRC-16 LHA). | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_BUYPASS () |
Returns a set of parameters for CRC-16 BUYPASS (aka CRC-16 VERIFONE, CRC-16 UMTS). | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_CCITTFALSE () |
Returns a set of parameters for CRC-16 CCITT FALSE. | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_MCRF4XX () |
Returns a set of parameters for CRC-16 MCRF4XX. | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_CDMA2000 () |
Returns a set of parameters for CRC-16 CDMA2000. | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_CMS () |
Returns a set of parameters for CRC-16 CMS. | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_DECTR () |
Returns a set of parameters for CRC-16 DECT-R (aka CRC-16 R-CRC). | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_DECTX () |
Returns a set of parameters for CRC-16 DECT-X (aka CRC-16 X-CRC). | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_DNP () |
Returns a set of parameters for CRC-16 DNP. | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_GENIBUS () |
Returns a set of parameters for CRC-16 GENIBUS (aka CRC-16 EPC, CRC-16 I-CODE, CRC-16 DARC). | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_KERMIT () |
Returns a set of parameters for CRC-16 KERMIT (aka CRC-16 CCITT, CRC-16 CCITT-TRUE). | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_MAXIM () |
Returns a set of parameters for CRC-16 MAXIM. | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_MODBUS () |
Returns a set of parameters for CRC-16 MODBUS. | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_T10DIF () |
Returns a set of parameters for CRC-16 T10-DIF. | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_USB () |
Returns a set of parameters for CRC-16 USB. | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_X25 () |
Returns a set of parameters for CRC-16 X-25 (aka CRC-16 IBM-SDLC, CRC-16 ISO-HDLC, CRC-16 B). | |
static const Parameters< crcpp_uint16, 16 > & | CRC_16_XMODEM () |
Returns a set of parameters for CRC-16 XMODEM (aka CRC-16 ZMODEM, CRC-16 ACORN, CRC-16 LTE). | |
static const Parameters< crcpp_uint32, 17 > & | CRC_17_CAN () |
Returns a set of parameters for CRC-17 CAN. | |
static const Parameters< crcpp_uint32, 21 > & | CRC_21_CAN () |
Returns a set of parameters for CRC-21 CAN. | |
static const Parameters< crcpp_uint32, 24 > & | CRC_24 () |
Returns a set of parameters for CRC-24 OPENPGP. | |
static const Parameters< crcpp_uint32, 24 > & | CRC_24_FLEXRAYA () |
Returns a set of parameters for CRC-24 FlexRay-A. | |
static const Parameters< crcpp_uint32, 24 > & | CRC_24_FLEXRAYB () |
Returns a set of parameters for CRC-24 FlexRay-B. | |
static const Parameters< crcpp_uint32, 24 > & | CRC_24_LTEA () |
Returns a set of parameters for CRC-24 LTE-A/NR-A. | |
static const Parameters< crcpp_uint32, 24 > & | CRC_24_LTEB () |
Returns a set of parameters for CRC-24 LTE-B/NR-B. | |
static const Parameters< crcpp_uint32, 24 > & | CRC_24_NRC () |
Returns a set of parameters for CRC-24 NR-C. | |
static const Parameters< crcpp_uint32, 30 > & | CRC_30 () |
Returns a set of parameters for CRC-30 CDMA. | |
static const Parameters< crcpp_uint32, 32 > & | CRC_32 () |
Returns a set of parameters for CRC-32 (aka CRC-32 ADCCP, CRC-32 PKZip). | |
static const Parameters< crcpp_uint32, 32 > & | CRC_32_BZIP2 () |
Returns a set of parameters for CRC-32 BZIP2 (aka CRC-32 AAL5, CRC-32 DECT-B, CRC-32 B-CRC). | |
static const Parameters< crcpp_uint32, 32 > & | CRC_32_C () |
Returns a set of parameters for CRC-32 C (aka CRC-32 ISCSI, CRC-32 Castagnoli, CRC-32 Interlaken). | |
static const Parameters< crcpp_uint32, 32 > & | CRC_32_MPEG2 () |
Returns a set of parameters for CRC-32 MPEG-2. | |
static const Parameters< crcpp_uint32, 32 > & | CRC_32_POSIX () |
Returns a set of parameters for CRC-32 POSIX. | |
static const Parameters< crcpp_uint32, 32 > & | CRC_32_Q () |
Returns a set of parameters for CRC-32 Q. | |
static const Parameters< crcpp_uint64, 40 > & | CRC_40_GSM () |
Returns a set of parameters for CRC-40 GSM. | |
static const Parameters< crcpp_uint64, 64 > & | CRC_64 () |
Returns a set of parameters for CRC-64 ECMA. | |
Static Private Member Functions | |
template<typename IntegerType> | |
static IntegerType | Reflect (IntegerType value, crcpp_uint16 numBits) |
Reflects (i.e. reverses the bits within) an integer value. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | Finalize (CRCType remainder, CRCType finalXOR, bool reflectOutput) |
Computes the final reflection and XOR of a CRC remainder. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | UndoFinalize (CRCType remainder, CRCType finalXOR, bool reflectOutput) |
Undoes the process of computing the final reflection and XOR of a CRC remainder. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | CalculateRemainder (const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters, CRCType remainder) |
Computes a CRC remainder. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | CalculateRemainder (const void *data, crcpp_size size, const Table< CRCType, CRCWidth > &lookupTable, CRCType remainder) |
Computes a CRC remainder using lookup table. | |
template<typename CRCType, crcpp_uint16 CRCWidth> | |
static CRCType | CalculateRemainderBits (unsigned char byte, crcpp_size numBits, const Parameters< CRCType, CRCWidth > ¶meters, CRCType remainder) |
Static class for computing CRCs.
|
delete |
|
delete |
|
delete |
|
inlinestatic |
|
inlinestatic |
Appends additional data to a previous CRC calculation.
[in] | data | Data over which CRC will be computed |
[in] | size | Size of the data, in bytes |
[in] | parameters | CRC parameters |
[in] | crc | CRC from a previous calculation |
CRCType | Integer type for storing the CRC result |
CRCWidth | Number of bits in the CRC |
|
inlinestatic |
|
inlinestatic |
Appends additional data to a previous CRC calculation using a lookup table.
[in] | data | Data over which CRC will be computed |
[in] | size | Size of the data, in bytes |
[in] | lookupTable | CRC lookup table |
[in] | crc | CRC from a previous calculation |
CRCType | Integer type for storing the CRC result |
CRCWidth | Number of bits in the CRC |
|
inlinestatic |
|
inlinestatic |
Appends additional data to a previous CRC calculation.
[in] | data | Data over which CRC will be computed |
[in] | size | Size of the data, in bits |
[in] | parameters | CRC parameters |
[in] | crc | CRC from a previous calculation |
CRCType | Integer type for storing the CRC result |
CRCWidth | Number of bits in the CRC |
|
inlinestatic |
|
inlinestatic |
Appends additional data to a previous CRC calculation using a lookup table.
[in] | data | Data over which CRC will be computed |
[in] | size | Size of the data, in bits |
[in] | lookupTable | CRC lookup table |
[in] | crc | CRC from a previous calculation |
CRCType | Integer type for storing the CRC result |
CRCWidth | Number of bits in the CRC |
|
inlinestaticprivate |
Computes a CRC remainder.
[in] | data | Data over which the remainder will be computed |
[in] | size | Size of the data, in bytes |
[in] | parameters | CRC parameters |
[in] | remainder | Running CRC remainder. Can be an initial value or the result of a previous CRC remainder calculation. |
CRCType | Integer type for storing the CRC result |
CRCWidth | Number of bits in the CRC |
|
inlinestaticprivate |
Computes a CRC remainder using lookup table.
[in] | data | Data over which the remainder will be computed |
[in] | size | Size of the data, in bytes |
[in] | lookupTable | CRC lookup table |
[in] | remainder | Running CRC remainder. Can be an initial value or the result of a previous CRC remainder calculation. |
CRCType | Integer type for storing the CRC result |
CRCWidth | Number of bits in the CRC |
|
inlinestaticprivate |
|
inlinestatic |
Returns a set of parameters for CRC-10 ITU.
|
inlinestatic |
Returns a set of parameters for CRC-10 CDMA2000.
|
inlinestatic |
Returns a set of parameters for CRC-11 FlexRay.
|
inlinestatic |
Returns a set of parameters for CRC-11 NR.
|
inlinestatic |
Returns a set of parameters for CRC-12 CDMA2000.
|
inlinestatic |
Returns a set of parameters for CRC-12 DECT (aka CRC-12 X-CRC).
|
inlinestatic |
Returns a set of parameters for CRC-12 UMTS (aka CRC-12 3GPP).
|
inlinestatic |
Returns a set of parameters for CRC-13 BBC.
|
inlinestatic |
Returns a set of parameters for CRC-15 CAN.
|
inlinestatic |
Returns a set of parameters for CRC-15 MPT1327.
|
inlinestatic |
Returns a set of parameters for CRC-16 ARC (aka CRC-16 IBM, CRC-16 LHA).
|
inlinestatic |
Returns a set of parameters for CRC-16 BUYPASS (aka CRC-16 VERIFONE, CRC-16 UMTS).
|
inlinestatic |
Returns a set of parameters for CRC-16 CCITT FALSE.
|
inlinestatic |
Returns a set of parameters for CRC-16 CDMA2000.
|
inlinestatic |
Returns a set of parameters for CRC-16 CMS.
|
inlinestatic |
Returns a set of parameters for CRC-16 DECT-R (aka CRC-16 R-CRC).
|
inlinestatic |
Returns a set of parameters for CRC-16 DECT-X (aka CRC-16 X-CRC).
|
inlinestatic |
Returns a set of parameters for CRC-16 DNP.
|
inlinestatic |
Returns a set of parameters for CRC-16 GENIBUS (aka CRC-16 EPC, CRC-16 I-CODE, CRC-16 DARC).
|
inlinestatic |
Returns a set of parameters for CRC-16 KERMIT (aka CRC-16 CCITT, CRC-16 CCITT-TRUE).
|
inlinestatic |
Returns a set of parameters for CRC-16 MAXIM.
|
inlinestatic |
Returns a set of parameters for CRC-16 MCRF4XX.
|
inlinestatic |
Returns a set of parameters for CRC-16 MODBUS.
|
inlinestatic |
Returns a set of parameters for CRC-16 T10-DIF.
|
inlinestatic |
Returns a set of parameters for CRC-16 USB.
|
inlinestatic |
Returns a set of parameters for CRC-16 X-25 (aka CRC-16 IBM-SDLC, CRC-16 ISO-HDLC, CRC-16 B).
|
inlinestatic |
Returns a set of parameters for CRC-16 XMODEM (aka CRC-16 ZMODEM, CRC-16 ACORN, CRC-16 LTE).
|
inlinestatic |
Returns a set of parameters for CRC-17 CAN.
|
inlinestatic |
Returns a set of parameters for CRC-21 CAN.
|
inlinestatic |
Returns a set of parameters for CRC-24 OPENPGP.
|
inlinestatic |
Returns a set of parameters for CRC-24 FlexRay-A.
|
inlinestatic |
Returns a set of parameters for CRC-24 FlexRay-B.
|
inlinestatic |
Returns a set of parameters for CRC-24 LTE-A/NR-A.
|
inlinestatic |
Returns a set of parameters for CRC-24 LTE-B/NR-B.
|
inlinestatic |
Returns a set of parameters for CRC-24 NR-C.
|
inlinestatic |
Returns a set of parameters for CRC-30 CDMA.
|
inlinestatic |
Returns a set of parameters for CRC-32 (aka CRC-32 ADCCP, CRC-32 PKZip).
|
inlinestatic |
Returns a set of parameters for CRC-32 BZIP2 (aka CRC-32 AAL5, CRC-32 DECT-B, CRC-32 B-CRC).
|
inlinestatic |
Returns a set of parameters for CRC-32 C (aka CRC-32 ISCSI, CRC-32 Castagnoli, CRC-32 Interlaken).
|
inlinestatic |
Returns a set of parameters for CRC-32 MPEG-2.
|
inlinestatic |
Returns a set of parameters for CRC-32 POSIX.
|
inlinestatic |
Returns a set of parameters for CRC-32 Q.
|
inlinestatic |
Returns a set of parameters for CRC-40 GSM.
|
inlinestatic |
Returns a set of parameters for CRC-4 ITU.
|
inlinestatic |
Returns a set of parameters for CRC-5 EPC.
|
inlinestatic |
Returns a set of parameters for CRC-5 ITU.
|
inlinestatic |
Returns a set of parameters for CRC-5 USB.
|
inlinestatic |
Returns a set of parameters for CRC-64 ECMA.
|
inlinestatic |
Returns a set of parameters for CRC-6 CDMA2000-A.
|
inlinestatic |
Returns a set of parameters for CRC-6 CDMA2000-B.
|
inlinestatic |
Returns a set of parameters for CRC-6 ITU.
|
inlinestatic |
Returns a set of parameters for CRC-6 NR.
|
inlinestatic |
Returns a set of parameters for CRC-7 JEDEC.
|
inlinestatic |
Returns a set of parameters for CRC-8 SMBus.
|
inlinestatic |
Returns a set of parameters for CRC-8 EBU (aka CRC-8 AES).
|
inlinestatic |
Returns a set of parameters for CRC-8 HDLC (ISO/IEC 13239:2002).
|
inlinestatic |
Returns a set of parameters for CRC-8 LTE.
|
inlinestatic |
Returns a set of parameters for CRC-8 MAXIM (aka CRC-8 DOW-CRC).
|
inlinestatic |
Returns a set of parameters for CRC-8 WCDMA.
|
inlinestaticprivate |
Computes the final reflection and XOR of a CRC remainder.
[in] | remainder | CRC remainder to reflect and XOR |
[in] | finalXOR | Final value to XOR with the remainder |
[in] | reflectOutput | true to reflect each byte of the remainder before the XOR |
CRCType | Integer type for storing the CRC result |
CRCWidth | Number of bits in the CRC |
|
inlinestaticprivate |
Reflects (i.e. reverses the bits within) an integer value.
[in] | value | Value to reflect |
[in] | numBits | Number of bits in the integer which will be reflected |
IntegerType | Integer type of the value being reflected |
|
inlinestaticprivate |
Undoes the process of computing the final reflection and XOR of a CRC remainder.
CRCType x = ...; CRCType y = Finalize(x, finalXOR, reflectOutput); CRCType z = UndoFinalize(y, finalXOR, reflectOutput); assert(x == z);
[in] | crc | Reflected and XORed CRC |
[in] | finalXOR | Final value XORed with the remainder |
[in] | reflectOutput | true if the remainder is to be reflected |
CRCType | Integer type for storing the CRC result |
CRCWidth | Number of bits in the CRC |