org.gudy.azureus2.core3.util
Class BrokenMd5Hasher

java.lang.Object
  extended by org.gudy.azureus2.core3.util.BrokenMd5Hasher

public final class BrokenMd5Hasher
extends Object

Use this class for getting a MD5 message digest. Create a MD5 and reuse it after a message digest calculation. There can be as many MD5 objects as you want to have multiple calculations same time. The message can be passed in one or a sequenze of parts wrapped in a ByteBuffer to the update of the same MD5 instance. To finish the calculation use final, it will reset the MD5 instance for a new calculation.

Version:
$Revision: 1.1 $
Last changed by $Author: parg $ on $Date: 2005-11-16 13:36:23 $
Author:
emarant

Constructor Summary
BrokenMd5Hasher()
          Constructor returns a MD6 ready for use.
 
Method Summary
 byte[] calculateHash(byte[] data)
           
 void finalDigest(ByteBuffer digest)
          Finishs a MD5 message digest calculation.
 byte[] getDigest()
           
 void reset()
          Resets the MD5 to initial state for a new message digest calculation.
 void update(byte[] data)
           
 void update(ByteBuffer input)
          Starts or continues a MD5 message digest calculation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrokenMd5Hasher

public BrokenMd5Hasher()
Constructor returns a MD6 ready for use.

Method Detail

calculateHash

public byte[] calculateHash(byte[] data)

reset

public void reset()
Resets the MD5 to initial state for a new message digest calculation.


update

public void update(ByteBuffer input)
Starts or continues a MD5 message digest calculation. input.remaining() should be a multiple of 64 to be most efficant, but other amounts work too. Only remaining bytes of the ByteBuffer are used and input.position() will be input.limit() after return.

Parameters:
input - hold a part of the message. input.order() have to be ByteOrder.LITTLE_ENDIAN

update

public void update(byte[] data)

getDigest

public byte[] getDigest()

finalDigest

public void finalDigest(ByteBuffer digest)
Finishs a MD5 message digest calculation. The result is stored in digest and the MD5-object is reset and so ready for a new message digest calculation.

Parameters:
digest - should be a ByteBuffer with digest.remaining() >= 16