2.17.2: 2011-06-17

net.sf.basedb.util
Class MD5

java.lang.Object
  extended by net.sf.basedb.util.MD5

public class MD5
extends Object

This class calculates the MD5 hash of a string and returns it represented as a hexadecimal string.

Version:
2.0
Author:
Nicklas

Constructor Summary
MD5()
           
 
Method Summary
static String getHashString(MessageDigest md5)
           
static String getHashString(String in)
          Calculates the MD5 hash of an UTF-8 encoded string.
static String leftPad(String toPad, char c, int length)
          If the string is shorter than the specified length, it is left padded with the specified character.
static MessageDigest newInstance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MD5

public MD5()
Method Detail

getHashString

public static String getHashString(String in)
Calculates the MD5 hash of an UTF-8 encoded string.


newInstance

public static MessageDigest newInstance()

getHashString

public static String getHashString(MessageDigest md5)

leftPad

public static String leftPad(String toPad,
                             char c,
                             int length)
If the string is shorter than the specified length, it is left padded with the specified character. If the string is null or longer than the specified length it is returned unchanged.

Parameters:
toPad - The string to pad
c - The character to pad with
length - The length of the resulting string
Returns:
The left-padded string

2.17.2: 2011-06-17