org.salespointframework.core.users
Class MD5

java.lang.Object
  extended by org.salespointframework.core.users.MD5

public final class MD5
extends java.lang.Object

An class for generating a securly encoded passwort string using the MD5 algorithm

Author:
Alexander Herrmann

Field Summary
private static char[] chHexchar
          An Array with all hexadecimal characters.
private static java.security.MessageDigest md5
          The MD5 generator.
 
Constructor Summary
MD5()
           
 
Method Summary
static java.lang.String byteToHex(byte[] b)
          Converts a byte-Array to hexadecimal string
static byte[] digestBytes(byte[] bData)
          Retrieves a byte sequence representing the MD5 digest of the specified byte sequence.
static byte[] digestString(java.lang.String sPhrase)
          Retrieves a byte sequence that represents the MD5 digest string.
static java.lang.String encodeString(java.lang.String sPhrase)
          Retrieves a hexadecimal character sequence representing the MD5 digest of the specified character sequence by using ISO-8859-1 encoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

md5

private static java.security.MessageDigest md5
The MD5 generator.


chHexchar

private static final char[] chHexchar
An Array with all hexadecimal characters. Needed for converting byte[] to hexadecimal

Constructor Detail

MD5

public MD5()
Method Detail

encodeString

public static final java.lang.String encodeString(java.lang.String sPhrase)
                                           throws java.lang.RuntimeException
Retrieves a hexadecimal character sequence representing the MD5 digest of the specified character sequence by using ISO-8859-1 encoding

Parameters:
sPhrase - the string to encode.
Returns:
a hexadecimal character sequence representing the MD5 digest of the specified string
Throws:
java.lang.RuntimeException - if an MD5 digest algorithm is not available through the java.security.MessageDigest spi

byteToHex

public static java.lang.String byteToHex(byte[] b)
Converts a byte-Array to hexadecimal string

Parameters:
b - the byte[] to be converted
Returns:
hexadecimal string

digestString

public static byte[] digestString(java.lang.String sPhrase)
                           throws java.lang.RuntimeException
Retrieves a byte sequence that represents the MD5 digest string. Used encoding is ISO-8859-1

Parameters:
sPhrase - the string to digest.
Returns:
the digest as an array of 16 bytes.
Throws:
java.lang.RuntimeException - if an MD5 digest algorithm is not available through the java.security.MessageDigest spi

digestBytes

public static final byte[] digestBytes(byte[] bData)
                                throws java.lang.RuntimeException
Retrieves a byte sequence representing the MD5 digest of the specified byte sequence.

Parameters:
bData - the data to digest.
Returns:
the MD5 digest as an array of 16 bytes.
Throws:
java.lang.RuntimeException - if an MD5 digest algorithm is not available through the java.security.MessageDigest spi