org.norther.tammi.acorn.security
Class MD5

java.lang.Object
  extended by org.norther.tammi.acorn.security.MD5

public abstract class MD5
extends Object

A static MD5 digest encoder.

The MD5 data contains 32 four bit sequences of hex chars.

Version:
$Id: MD5.java,v 1.6 2009/09/28 15:08:48 cvsimp Exp $
Author:
Ilkka Priha

Field Summary
static int LENGTH
          The MD5 hash length.
 
Constructor Summary
MD5()
           
 
Method Summary
static byte[] digest(byte[] data)
          Calculates the digest for the specified data.
static byte[] digest(String string)
          Calculates the digest for the specified string by applying platform's default encoding.
static byte[] digest(String string, String encoding)
          Calculates the digest for the specified string by applying the specified encoding.
static String encode(byte[] data)
          Encodes MD5 data into a 32 char MD5 string.
static String encode(String string)
          Encodes a string into a 32 char MD5 string by calculating the digest using the specified string and encoding the resulting MD5 data.
static String encode(String string, String encoding)
          Encodes a string into a 32 char MD5 string by calculating the digest using the specified string and encoding the resulting MD5 data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LENGTH

public static final int LENGTH
The MD5 hash length.

See Also:
Constant Field Values
Constructor Detail

MD5

public MD5()
Method Detail

encode

public static final String encode(String string)
Encodes a string into a 32 char MD5 string by calculating the digest using the specified string and encoding the resulting MD5 data. Platform's default encoding is applied to the string when converting it into MD5 data.

Parameters:
string - the string to encode.
Returns:
the encoded MD5 string or null.

encode

public static final String encode(String string,
                                  String encoding)
Encodes a string into a 32 char MD5 string by calculating the digest using the specified string and encoding the resulting MD5 data. The specified encoding is applied to the string when converting it into MD5 data.

Parameters:
string - the string to encode.
encoding - the character encoding.
Returns:
the encoded MD5 string or null.

encode

public static final String encode(byte[] data)
Encodes MD5 data into a 32 char MD5 string.

Parameters:
data - an array containing the digest.
Returns:
the encoded MD5 string or null.

digest

public static final byte[] digest(String string)
Calculates the digest for the specified string by applying platform's default encoding.

Parameters:
string - the update string.
Returns:
the digest as an array of bytes.
Throws:
IllegalStateException - if a digest generator is not available.

digest

public static final byte[] digest(String string,
                                  String encoding)
Calculates the digest for the specified string by applying the specified encoding.

Parameters:
string - the update string.
encoding - the character encoding.
Returns:
the digest as an array of bytes.
Throws:
IllegalStateException - if a digest generator is not available.

digest

public static final byte[] digest(byte[] data)
Calculates the digest for the specified data.

Parameters:
data - the update data.
Returns:
the digest as an array of bytes.
Throws:
NullPointerException - if a digest generator is not available.


Copyright © 2004 The Norther Organization. All rights reserved.