Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

cryptix.openpgp.util
Class PGPCRC  view PGPCRC download PGPCRC.java

java.lang.Object
  extended bycryptix.openpgp.util.PGPCRC
All Implemented Interfaces:
java.util.zip.Checksum

public final class PGPCRC
extends java.lang.Object
implements java.util.zip.Checksum

CRC checksum as required by OpenPGP base64 encoded packets.

Version:
$Revision: 1.2 $

Field Summary
private  int accum
          Running CRC
private static int ACCUM_INIT
          Initial accumulator value
private static int[] crctable
           
 
Constructor Summary
PGPCRC()
          Construct a virgin PGPCRC
 
Method Summary
static int checksum(byte[] buf)
          Convenience method to calculate PGP CRC over a given buffer.
private static int checksum(int accum, byte[] buf)
          Update the given CRC with the data in the given buffer.
 long getValue()
          Returns the current value of the CRC.
 void reset()
          Resets the data checksum as if no update was ever called.
 void update(byte[] buf)
          Update the CRC with the contents of the buffer.
 void update(byte[] buf, int off, int len)
          Update the CRC with the contents of the buffer.
 void update(int b)
          Update CRC with given byte.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

crctable

private static final int[] crctable

ACCUM_INIT

private static final int ACCUM_INIT
Initial accumulator value

See Also:
Constant Field Values

accum

private int accum
Running CRC

Constructor Detail

PGPCRC

public PGPCRC()
Construct a virgin PGPCRC

Method Detail

checksum

public static int checksum(byte[] buf)
Convenience method to calculate PGP CRC over a given buffer.


update

public final void update(byte[] buf)
Update the CRC with the contents of the buffer.


update

public final void update(byte[] buf,
                         int off,
                         int len)
Update the CRC with the contents of the buffer.

Specified by:
update in interface java.util.zip.Checksum

update

public final void update(int b)
Update CRC with given byte.

Specified by:
update in interface java.util.zip.Checksum

getValue

public final long getValue()
Returns the current value of the CRC.

Specified by:
getValue in interface java.util.zip.Checksum

reset

public void reset()
Description copied from interface: java.util.zip.Checksum
Resets the data checksum as if no update was ever called.

Specified by:
reset in interface java.util.zip.Checksum

checksum

private static int checksum(int accum,
                            byte[] buf)
Update the given CRC with the data in the given buffer.