19static std::vector<unsigned long> gen_crc_table() {
21 static const unsigned long POLYNOMIAL = 0x04c11db7UL;
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;
37unsigned long crc32ul(
const std::string & s) {
38 static 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;
const unsigned long FAR crc_table[TBLS][256]
unsigned long crc32ul(const std::string &s)