Class marimba.util.Checksum
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class marimba.util.Checksum

java.lang.Object
   |
   +----marimba.util.Checksum

public class Checksum
extends Object
This represents a checksum for an array of bytes or a file. The checksum is a 128 bit value and is computed using the MD5 algorithm. The checksum can be converted to a 27 character string representation (two unsigned base 32 numbers).
Version:
1.13, 01/16/97
Author:
Jonathan Payne, Arthur van Hoff

Variable Index

 o BLOCK
Unit size in bytes that checksums are calculated by.
 o BLOCK_MASK
 o checksum1
The checksum.
 o checksum2
 o nullChecksum

Constructor Index

 o Checksum()
Create an empty checksum.
 o Checksum(char[])
Create a checksum from an array of characaters.
 o Checksum(char[], int, int)
Create a checksum from an array of characaters.
 o Checksum(FastInputStream)
Read a checksum from an input stream.
 o Checksum(long, long)
Create a checksum from two longs.
 o Checksum(long[])
Create a checksum from an array of two longs.
 o Checksum(String)
Create a checksum from a string.

Method Index

 o combine(Checksum)
 o equals(long, long)
Check if a checksum is equal to two longs.
 o equals(Object)
Check if a checksum is equal to another object.
 o getChecksum1()
Get the first 64 bits of the checksum.
 o getChecksum2()
Get the second 64 bits of the checksum.
 o hashCode()
Compute a hash code for the checksum.
 o main(String[])
For testing purposes only.
 o MD5(byte[], int, int)
Compute the MD5 checksum for a buffer of bytes.
 o MD5(InputStream)
Compute the MD5 checksum for an input stream.
 o MD5Add(byte[], int, int[])
Add 64 bytes to the digest.
 o MD5Digest()
Create a new digest
 o MD5Finish(byte[], int, int, long, int[])
Finish computation of the digest.
 o setChecksum0(Checksum)
Set the checksum to the value of another checksum.
 o toArray()
Return an array of two longs.
 o toHexString()
Convert the checksum to a hexadecimal string.
 o toString()
Convert the checksum to a 27 character string.
 o valid()
Check if the checksum is not 0.
 o writeChecksum(FastOutputStream)
Write the checksum to an output stream.

Variables

 o nullChecksum
  public static Checksum nullChecksum
 o BLOCK
  public final static int BLOCK
Unit size in bytes that checksums are calculated by.
 o BLOCK_MASK
  public final static int BLOCK_MASK
 o checksum1
  protected long checksum1
The checksum.
 o checksum2
  protected long checksum2

Constructors

 o Checksum
  public Checksum(String val)
Create a checksum from a string. The string must be 27 characters long.
 o Checksum
  public Checksum(char str[])
Create a checksum from an array of characaters. The array must be 27 characters long.
 o Checksum
  public Checksum(char str[],
                  int off,
                  int len)
Create a checksum from an array of characaters. The length must be 27 characters.
 o Checksum
  public Checksum(long cs[])
Create a checksum from an array of two longs.
 o Checksum
  public Checksum(long checksum1,
                  long checksum2)
Create a checksum from two longs.
 o Checksum
  public Checksum(FastInputStream in)
Read a checksum from an input stream.
 o Checksum
  protected Checksum()
Create an empty checksum.

Methods

 o getChecksum1
  public final long getChecksum1()
Get the first 64 bits of the checksum.
 o getChecksum2
  public final long getChecksum2()
Get the second 64 bits of the checksum.
 o valid
  public boolean valid()
Check if the checksum is not 0.
 o hashCode
  public int hashCode()
Compute a hash code for the checksum.
Overrides:
hashCode in class Object
 o equals
  public boolean equals(long checksum1,
                        long checksum2)
Check if a checksum is equal to two longs.
 o equals
  public boolean equals(Object o)
Check if a checksum is equal to another object.
Overrides:
equals in class Object
 o combine
  public Checksum combine(Checksum other)
 o setChecksum0
  protected void setChecksum0(Checksum cs)
Set the checksum to the value of another checksum. Use with care.
 o toArray
  public long[] toArray()
Return an array of two longs.
 o writeChecksum
  public void writeChecksum(FastOutputStream out)
Write the checksum to an output stream.
 o toString
  public String toString()
Convert the checksum to a 27 character string.
Overrides:
toString in class Object
 o toHexString
  public String toHexString()
Convert the checksum to a hexadecimal string.
 o MD5Digest
  public static int[] MD5Digest()
Create a new digest
 o MD5Add
  public static void MD5Add(byte buf[],
                            int i,
                            int digest[])
Add 64 bytes to the digest. The digest (the checksum) consists of 4 integers.
 o MD5Finish
  public static Checksum MD5Finish(byte data[],
                                   int off,
                                   int len,
                                   long total,
                                   int digest[])
Finish computation of the digest. Must pass the remaining bytes (always fewer than 64). This method return the checksum.
 o MD5
  public static Checksum MD5(byte data[],
                             int offset,
                             int len)
Compute the MD5 checksum for a buffer of bytes.
 o MD5
  public static Checksum MD5(InputStream in) throws IOException
Compute the MD5 checksum for an input stream. The stream is read 64 bytes at a time until the EOF is reached.
 o main
  public static void main(String argv[]) throws IOException
For testing purposes only.

All Packages  Class Hierarchy  This Package  Previous  Next  Index