cz.cuni.jagrlib
Class Crc32

java.lang.Object
  extended by cz.cuni.jagrlib.Crc32

public class Crc32
extends java.lang.Object

32-bit checksum. Uses polynomial "x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1".

Copyright © 1995-1996 by Mark Adler, adopted 2001-2004 by J.Pelikan

Polynomials over GF(2) are represented in binary, one bit per coefficient, with the lowest powers in the most significant bit. Then adding polynomials is just exclusive-or, and multiplying a polynomial by x is a right shift by one. If we call the above polynomial p, and represent a byte as the polynomial q, also with the lowest power in the most significant bit (so the byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, where a mod b means the remainder after dividing a by b.

Since:
0.24
See Also:
Crc32.java

Constructor Summary
Crc32()
           
 
Method Summary
static long compute(long crc, byte[] data, int from, int len)
          Crc32 checksum over part of the byte[] array.
static long compute(long crc, char[] data, int from, int len)
          Crc32 checksum over part of the char[] array.
static long compute(long crc, java.lang.String str, int from, int len)
          Crc32 checksum over part of the String.
static long step(long crc, int val)
          One step of crc32 computation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Crc32

public Crc32()
Method Detail

step

public static final long step(long crc,
                              int val)
One step of crc32 computation.


compute

public static long compute(long crc,
                           byte[] data,
                           int from,
                           int len)
Crc32 checksum over part of the byte[] array.


compute

public static long compute(long crc,
                           char[] data,
                           int from,
                           int len)
Crc32 checksum over part of the char[] array.


compute

public static long compute(long crc,
                           java.lang.String str,
                           int from,
                           int len)
Crc32 checksum over part of the String.