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
-
BLOCK
- Unit size in bytes that checksums are calculated by.
-
BLOCK_MASK
-
-
checksum1
- The checksum.
-
checksum2
-
-
nullChecksum
-
-
Checksum()
- Create an empty checksum.
-
Checksum(char[])
- Create a checksum from an array of characaters.
-
Checksum(char[], int, int)
- Create a checksum from an array of characaters.
-
Checksum(FastInputStream)
- Read a checksum from an input stream.
-
Checksum(long, long)
- Create a checksum from two longs.
-
Checksum(long[])
- Create a checksum from an array of two longs.
-
Checksum(String)
- Create a checksum from a string.
-
combine(Checksum)
-
-
equals(long, long)
- Check if a checksum is equal to two longs.
-
equals(Object)
- Check if a checksum is equal to another object.
-
getChecksum1()
- Get the first 64 bits of the checksum.
-
getChecksum2()
- Get the second 64 bits of the checksum.
-
hashCode()
- Compute a hash code for the checksum.
-
main(String[])
- For testing purposes only.
-
MD5(byte[], int, int)
- Compute the MD5 checksum for a buffer of bytes.
-
MD5(InputStream)
- Compute the MD5 checksum for an input stream.
-
MD5Add(byte[], int, int[])
- Add 64 bytes to the digest.
-
MD5Digest()
- Create a new digest
-
MD5Finish(byte[], int, int, long, int[])
- Finish computation of the digest.
-
setChecksum0(Checksum)
- Set the checksum to the value of another checksum.
-
toArray()
- Return an array of two longs.
-
toHexString()
- Convert the checksum to a hexadecimal string.
-
toString()
- Convert the checksum to a 27 character string.
-
valid()
- Check if the checksum is not 0.
-
writeChecksum(FastOutputStream)
- Write the checksum to an output stream.
nullChecksum
public static Checksum nullChecksum
BLOCK
public final static int BLOCK
- Unit size in bytes that checksums are calculated by.
BLOCK_MASK
public final static int BLOCK_MASK
checksum1
protected long checksum1
- The checksum.
checksum2
protected long checksum2
Checksum
public Checksum(String val)
- Create a checksum from a string. The string
must be 27 characters long.
Checksum
public Checksum(char str[])
- Create a checksum from an array of characaters. The array
must be 27 characters long.
Checksum
public Checksum(char str[],
int off,
int len)
- Create a checksum from an array of characaters. The length
must be 27 characters.
Checksum
public Checksum(long cs[])
- Create a checksum from an array of two longs.
Checksum
public Checksum(long checksum1,
long checksum2)
- Create a checksum from two longs.
Checksum
public Checksum(FastInputStream in)
- Read a checksum from an input stream.
Checksum
protected Checksum()
- Create an empty checksum.
getChecksum1
public final long getChecksum1()
- Get the first 64 bits of the checksum.
getChecksum2
public final long getChecksum2()
- Get the second 64 bits of the checksum.
valid
public boolean valid()
- Check if the checksum is not 0.
hashCode
public int hashCode()
- Compute a hash code for the checksum.
- Overrides:
- hashCode in class Object
equals
public boolean equals(long checksum1,
long checksum2)
- Check if a checksum is equal to two longs.
equals
public boolean equals(Object o)
- Check if a checksum is equal to another object.
- Overrides:
- equals in class Object
combine
public Checksum combine(Checksum other)
setChecksum0
protected void setChecksum0(Checksum cs)
- Set the checksum to the value of another checksum.
Use with care.
toArray
public long[] toArray()
- Return an array of two longs.
writeChecksum
public void writeChecksum(FastOutputStream out)
- Write the checksum to an output stream.
toString
public String toString()
- Convert the checksum to a 27 character string.
- Overrides:
- toString in class Object
toHexString
public String toHexString()
- Convert the checksum to a hexadecimal string.
MD5Digest
public static int[] MD5Digest()
- Create a new digest
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.
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.
MD5
public static Checksum MD5(byte data[],
int offset,
int len)
- Compute the MD5 checksum for a buffer of bytes.
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.
main
public static void main(String argv[]) throws IOException
- For testing purposes only.
All Packages Class Hierarchy This Package Previous Next Index