21 static const unsigned long POLYNOMIAL = 0x04c11db7UL;
22 std::vector<unsigned long> crc_table;
23 for (
unsigned long i = 0; i < 256; ++i ) {
24 unsigned long crc = i << 24;
25 for (
int j = 0; j < 8; j++ ) {
26 if ( crc & 0x80000000UL ) {
27 crc = ( ( crc << 1 ) ^ POLYNOMIAL ) & 0xffffffffUL;
29 crc = ( crc << 1 ) & 0xffffffffUL;
32 crc_table.push_back(crc);
38 static const std::vector<unsigned long> crc_table =
gen_crc_table();
39 unsigned long crc = 0;
41 for (
int j = 0; j != end; ++j) {
42 int i = ( (int) ( crc >> 24) ^ s[j] ) & 0xff;
43 crc = ( ( crc << 8 ) ^ crc_table[i] ) & 0xffffffffUL;
static std::vector< unsigned long > gen_crc_table()
static constexpr double s
unsigned long crc32ul(const std::string &s)