Secure iNet Factory

com.jscape.inet.util
Class MD5

java.lang.Object
  extended by com.jscape.inet.util.MD5

public class MD5
extends java.lang.Object

Implements basic MD5 hash functionality based on algorithm described in RFC 1321.

Example Usage:

 String data = "secret";
 MD5 hash = new MD5(data);
 String hashValue = hash.getHash();
 

Example Usage for keyed hashing:

 String data = "secret";
 String key = "confidential";
 MD5 hash = new MD5(data,key);
 String hashValue = hash.getHash();
 


Constructor Summary
MD5(byte[] bytes)
          Constructs new MD5 instance.
MD5(byte[] value, byte[] keyvalue)
          Constructs new MD5 instance.
MD5(java.lang.String value)
          Constructs new MD5 instance.
MD5(java.lang.String value, java.lang.String keyvalue)
          Constructs new MD5 instance.
 
Method Summary
 byte[] fromHexString(java.lang.String s)
          fromHexString() function is to convert hex string to array of bytes.
 java.lang.String getHash()
          Gets hash representation of this MD5.
 java.lang.String toString()
          Gets hash representation of this MD5.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MD5

public MD5(java.lang.String value)
Constructs new MD5 instance.

Parameters:
value - the String value to hash

MD5

public MD5(byte[] bytes)
Constructs new MD5 instance.

Parameters:
bytes - a byte[] to hash

MD5

public MD5(java.lang.String value,
           java.lang.String keyvalue)
Constructs new MD5 instance.

Parameters:
value - the String to hash
keyvalue - the String used as secret key

MD5

public MD5(byte[] value,
           byte[] keyvalue)
Constructs new MD5 instance.

Parameters:
value - a byte[] to hash
keyvalue - a byte[] to use for secret key
Method Detail

fromHexString

public byte[] fromHexString(java.lang.String s)
fromHexString() function is to convert hex string to array of bytes.

Parameters:
s - - Hex characters
Returns:
value a byte[]of hex string

toString

public java.lang.String toString()
Gets hash representation of this MD5. Same as invoking getHash method.

Overrides:
toString in class java.lang.Object
Returns:
hash

getHash

public java.lang.String getHash()
Gets hash representation of this MD5.

Returns:
hash value

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved