unsigned int generate_crc32c(const char *buffer, int length) {
int i;
unsigned int crc32 = ~0L; for (i = 0; i < length; i++) {
CRC32C(crc32, (unsigned char)buffer[i]);
}
return ~crc32;
}

解决方案 »

  1.   

    public static long generate_crc32c(String buffer, int length) {
    long crc32 = Long.parseLong(Integer.toHexString(~0), 16);
    long retValue = crc32;
    for (int i = 0; i < length; i++) {
    retValue = CRC32C(retValue, buffer.charAt(i));//2504045949
    }
    return Long.parseLong(Integer.toHexString(~(int) retValue), 16);
    }