Class CRC32

java.lang.Object
net.sf.jazzlib.CRC32
All Implemented Interfaces:
Checksum

public class CRC32 extends Object implements Checksum
Computes CRC32 data checksum of a data stream. The actual CRC32 algorithm is described in RFC 1952 (GZIP file format specification version 4.3). Can be used to get the CRC32 over a stream if used with checked input/output streams.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    The crc data checksum so far.
    private static int[]
    The fast CRC table.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the CRC32 data checksum computed so far.
    private static int[]
    Make the table for a fast CRC.
    void
    Resets the CRC32 data checksum as if no update was ever called.
    void
    update(byte[] buf)
    Adds the complete byte array to the data checksum.
    void
    update(byte[] buf, int off, int len)
    Adds the byte array to the data checksum.
    void
    update(int bval)
    Updates the checksum with the int bval.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • crc

      private int crc
      The crc data checksum so far.
    • crc_table

      private static int[] crc_table
      The fast CRC table. Computed once when the CRC32 class is loaded.
  • Constructor Details

    • CRC32

      public CRC32()
  • Method Details

    • make_crc_table

      private static int[] make_crc_table()
      Make the table for a fast CRC.
    • getValue

      public long getValue()
      Returns the CRC32 data checksum computed so far.
      Specified by:
      getValue in interface Checksum
    • reset

      public void reset()
      Resets the CRC32 data checksum as if no update was ever called.
      Specified by:
      reset in interface Checksum
    • update

      public void update(int bval)
      Updates the checksum with the int bval.
      Specified by:
      update in interface Checksum
      Parameters:
      bval - (the byte is taken as the lower 8 bits of bval)
    • update

      public void update(byte[] buf, int off, int len)
      Adds the byte array to the data checksum.
      Specified by:
      update in interface Checksum
      Parameters:
      buf - the buffer which contains the data
      off - the offset in the buffer where the data starts
      len - the length of the data
    • update

      public void update(byte[] buf)
      Adds the complete byte array to the data checksum.