FileDocCategorySizeDatePackage
CRC32.javaAPI DocGlassfish v2 API6364Fri May 04 22:34:38 BST 2007com.sun.jdo.api.persistence.enhancer.util

CRC32

public class CRC32 extends Object
CRC32 provides CRC computation for the zip file code

Fields Summary
static int[]
CRCTable
Constructors Summary
Methods Summary
static intcomputeCRC(int crc, byte[] buf, int len)
Compute the CRC for "len" bytes in "buf"

    if (buf == null) return 0;

    int bufIndex = 0;
    crc = crc ^ 0xffffffff;
    while (len >= 8) {
	crc = CRCTable[(crc ^ ((int) buf[bufIndex++])) & 0xff] ^ (crc >>> 8);
	crc = CRCTable[(crc ^ ((int) buf[bufIndex++])) & 0xff] ^ (crc >>> 8);
	crc = CRCTable[(crc ^ ((int) buf[bufIndex++])) & 0xff] ^ (crc >>> 8);
	crc = CRCTable[(crc ^ ((int) buf[bufIndex++])) & 0xff] ^ (crc >>> 8);
	crc = CRCTable[(crc ^ ((int) buf[bufIndex++])) & 0xff] ^ (crc >>> 8);
	crc = CRCTable[(crc ^ ((int) buf[bufIndex++])) & 0xff] ^ (crc >>> 8);
	crc = CRCTable[(crc ^ ((int) buf[bufIndex++])) & 0xff] ^ (crc >>> 8);
	crc = CRCTable[(crc ^ ((int) buf[bufIndex++])) & 0xff] ^ (crc >>> 8);
      len -= 8;
    }

    if (len != 0)
      do {
	crc = CRCTable[(crc ^ ((int) buf[bufIndex++])) & 0xff] ^ (crc >>> 8);
      } while ((--len) > 0);
    return crc ^ 0xffffffff;