/** * This function computes / refreshes a crc32 checksum. * * @param table this is the precomputed crc32 table * @param crc set this value to zero if starting the computation or to the last retrieved value * when processing further data. * @param buffer the buffer to be walked * @param off the offset to start * @param len the amount of bytes to process * @return the new/refreshed crc checksum */ public static int crc32(int[] table, int crc, byte[] buffer, int off, int len) { if (table[2] == 0) { initCrc32Table(table); } crc = crc ^ 0xffffffff; for (int n = 0; n < len; n++) { crc = table[(crc ^ buffer[n + off]) & 0xff] ^ (crc >>> 8); } return 0xffffffff ^ crc; }