Skip to content

jopadan/crcle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crcle

CRC checksum C++ library

Status

namespace poly
{
	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 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 <cstdlib>
#include <cstdio>
#include <crcle/crcle.hpp>

int main(int argc, char** argv)
{
    exit(crc32::mpeg2::check() && crc32::ccitt::check() && crc32::iscsi::check() ? EXIT_SUCCESS : EXIT_FAILURE);
}

References