utils
Class MD5
java.lang.Object
|
+--utils.MD5
- public final class MD5
- extends java.lang.Object
Implementation of RSA's MD5 hash generator
This code is loosely based on the RSA reference implementation
and an early Java port of it by Santeri Paavolainen.
Objects of this class are single use only -- clients must
ensure that only one hash is computed, and sequentially too.
Hashes are returned as an array of 16 bytes.
Usage:
byte[] hash = MD5.hash(bytes); [single pass mode]
MD5 digest = new MD5(); [multiple pass mode]
digest.update(bytes);
digest.update(morebytes);
byte[] hash = digest.hash();
Constructor Summary |
MD5()
|
Method Summary |
byte[] |
hash()
|
static byte[] |
hash(byte[] buf)
|
static byte[] |
hash(byte[] buf,
int off,
int len)
|
static void |
main(java.lang.String[] args)
Runs RSA driver testsuite to check that the hash is correct |
static java.lang.String |
toString(byte[] hash)
|
void |
update(byte[] buf)
|
void |
update(byte[] buf,
int offset,
int length)
|
void |
update(java.lang.String s)
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
MD5
public MD5()
update
public void update(byte[] buf,
int offset,
int length)
update
public void update(byte[] buf)
update
public void update(java.lang.String s)
hash
public byte[] hash()
hash
public static byte[] hash(byte[] buf,
int off,
int len)
hash
public static byte[] hash(byte[] buf)
toString
public static java.lang.String toString(byte[] hash)
main
public static void main(java.lang.String[] args)
throws java.lang.Exception
- Runs RSA driver testsuite to check that the hash is correct