Skip to content

joneqdaniel/crcle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crcle

CRC checksum C++ library

Status

namespace poly
{
	const type<16> crc16                 = 0x8005;
	const type<32> inverse               = (type<32>)-1;
	const type<32> neutral               = (type<32>) 0;
	const type<32> crc32                 = 0x04C11DB7;
	const type<32> crc32_ieee            = reflect<32>(crc32);
	const type<32> crc32_iscsi           = 0x1EDC6F41;
	const type<32> crc32k_koopman_1_3_28 = 0x741B8CD7;
	const type<32> crc32k_koopman_1_1_30 = 0x32583499;
	const type<32> crc32q                = 0x814141AB;
};

namespace crc16
{
	namespace name
	{
		const char* arc = "CRC-16/ARC";
	};
	using arc = crc<16, poly::crc16, 0, 0, poly::ref_out | poly::ref_in, 0xBB3D, &name::arc>;
};
namespace crc32
{
	namespace name
	{
		const char* mpeg2 = "CRC-32/MPEG2";
		const char* ccitt = "CRC-32/CCITT";
		const char* iscsi = "CRC-32/ISCSI";
	};
	using mpeg2 = crc<32, poly::crc32, poly::inverse, poly::neutral, poly::ref_none, 0x0376E6E7, &name::mpeg2>;
	using ccitt = crc<32, poly::crc32, poly::inverse, poly::inverse, poly::ref_none, 0xFC891918, &name::ccitt>;
	using iscsi = crc<32, poly::crc32_iscsi, poly::inverse, poly::inverse, poly::ref_out | poly::ref_in, 0xE3069283, &name::iscsi>;
};

Usage

#include <crcle/crcle.hpp>

int main(int argc, char** argv)
{
	exit(crc32::  zip::hdr() &&
	     puts("")            &&
	     crc16::  arc::chk() &&
	     crc32::  zip::chk() &&
	     crc32::iscsi::chk() &&
	     crc32::mpeg2::chk() &&
	     crc32::ccitt::chk() ? 
	     EXIT_SUCCESS : EXIT_FAILURE);
}

Output

[HDR] CRC-BITS/VARIANT                   POLY   EXPECTED  ACTUAL   MAGIC  

[CHK] CRC-16/ARC                       00008005 0000BB3D 0000BB3D 0000CE32
[CHK] CRC-32/ZIP                       04C11DB7 FC891918 FC891918 890DA76C
[CHK] CRC-32/ISCSI                     1EDC6F41 E3069283 E3069283 92E27DD9
[CHK] CRC-32/MPEG2                     04C11DB7 0376E6E7 0376E6E7 C358080B
[CHK] CRC-32/CCITT                     04C11DB7 FC891918 FC891918 890DA76C

CRC variant synonyms

  • CRC-32/ISCSI, CRC-32/BASE91-C, CRC-32/CASTAGNOLI, CRC-32/INTERLAKEN, CRC-32C
  • CRC-32/BZIP2, CRC-32/AAL5, CRC-32/DECT-B, B-CRC-32
  • CRC-32/AIXM, CRC-32Q
  • CRC-32/BASE91-D, CRC-32D
  • CRC-32/ISO-HDLC, CRC-32, CRC-32/ADCCP, CRC-32/V-42, CRC-32/XZ, PKZIP
  • CRC-32/CKSUM, CKSUM, CRC-32/POSIX
  • CRC-32/JAMCRC, JAMCRC

Applications

References

Releases

No releases published

Packages

 
 
 

Contributors