10 constexpr uint32_t POLYNOMIAL = 0xEDB88320;
12 std::array<uint32_t, 0x100> table{};
14 for (uint32_t i = 0; i < 0x100; ++i)
17 for (uint32_t bit = 0; bit < 8; ++bit)
18 item = ((item & 1) != 0) ? (POLYNOMIAL ^ (item >> 1)) : (item >> 1);
25 inline constexpr uint32_t
crc_uint32(
const uint8_t* bytes, uint32_t size)
27 uint32_t result = 0xFFFFFFFF;
29 for (uint32_t i = 0; i < size; i++)
30 result =
CHECKSUM_TABLE[(result & 0xFF) ^ *(bytes + i)] ^ (result >> 8);
35 inline constexpr uint32_t
crc_uint32(
const uint8_t* checksum,
const uint8_t* bytes, uint32_t size)
37 uint32_t result = 0xFFFFFFFF;
39 for (uint32_t i = 0; i < 4; i++)
40 result =
CHECKSUM_TABLE[(result & 0xFF) ^ *(checksum + i)] ^ (result >> 8);
42 for (uint32_t i = 0; i < size; i++)
43 result =
CHECKSUM_TABLE[(result & 0xFF) ^ *(bytes + i)] ^ (result >> 8);
constexpr auto CHECKSUM_TABLE
Definition: crc.h:8
constexpr uint32_t crc_uint32(const uint8_t *bytes, uint32_t size)
Definition: crc.h:25