edu.uiuc.ndiipp.hubandspoke.utils
Class HaSChecksummer

java.lang.Object
  extended by edu.uiuc.ndiipp.hubandspoke.utils.HaSChecksummer
All Implemented Interfaces:
java.util.zip.Checksum

public class HaSChecksummer
extends java.lang.Object
implements java.util.zip.Checksum

Gives us checksums!

To be used in conjunction with a CheckedInputStream. Digests are computed as bytes are read from the stream.

For example:

HaSChecksummer summer = new HaSChecksummer(); File temp = readFile(new CheckedInputStream(new FileInputStream("/var/temp/file"), summer));

Author:
cordial
See Also:
CheckedInputStream, Checksum

Constructor Summary
HaSChecksummer()
           
 
Method Summary
 java.lang.String getBase64EncodedMD5()
          Returns the value of the MD5 digest as a Base64 encoded string.
 java.lang.String getBase64EncodedSHA1()
          Returns the value of the SHA1 digest as a Base64 encoded string.
 java.util.zip.CRC32 getCRC32()
           
 java.lang.String getHexEncodedMD5()
          Returns the value of the MD5 digest as a Hex encoded string.
 java.lang.String getHexEncodedSHA1()
          Returns the value of the SHA1 digest as a Hex encoded string.
 long getLongCRC32()
          Returns the value of the CRC32 checksum as a long.
 java.security.MessageDigest getMd5Digest()
          Getter for the raw MD5 Digest
 java.security.MessageDigest getSha1Digest()
          Getter for the raw SHA1 digest
 long getValue()
           
 void reset()
          clear!
 void update(byte b)
          Updates the checksum with the argument.
 void update(byte[] b)
          Updates the checksum with the argument.
 void update(byte[] b, int off, int len)
          Updates the checksum with the argument.
 void update(int b)
          Updates the checksum with the argument.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HaSChecksummer

public HaSChecksummer()
Method Detail

getCRC32

public java.util.zip.CRC32 getCRC32()

getMd5Digest

public java.security.MessageDigest getMd5Digest()
Getter for the raw MD5 Digest

Returns:
- md5

getSha1Digest

public java.security.MessageDigest getSha1Digest()
Getter for the raw SHA1 digest

Returns:
- sha1

getValue

public long getValue()
Specified by:
getValue in interface java.util.zip.Checksum

reset

public void reset()
clear!

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

update

public void update(byte b)
Updates the checksum with the argument. Called when a signed byte is available.


update

public void update(int b)
Updates the checksum with the argument. Called when an unsigned byte is available.

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

update

public void update(byte[] b)
Updates the checksum with the argument. Called when a byte array is available.


update

public void update(byte[] b,
                   int off,
                   int len)
Updates the checksum with the argument. Called when a byte array is available.

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

getBase64EncodedMD5

public java.lang.String getBase64EncodedMD5()
Returns the value of the MD5 digest as a Base64 encoded string. Returns null if the digest is not available.


getBase64EncodedSHA1

public java.lang.String getBase64EncodedSHA1()
Returns the value of the SHA1 digest as a Base64 encoded string. Returns null if the digest is not available.


getHexEncodedMD5

public java.lang.String getHexEncodedMD5()
Returns the value of the MD5 digest as a Hex encoded string. Returns null if the digest is not available.


getHexEncodedSHA1

public java.lang.String getHexEncodedSHA1()
Returns the value of the SHA1 digest as a Hex encoded string. Returns null if the digest is not available.


getLongCRC32

public long getLongCRC32()
Returns the value of the CRC32 checksum as a long.



Copyright © 2006, University of Illinois.