public static String md5(java.lang.String message){
  try {
    MessageDigest md=MessageDigest.getInstance("MD5");
    StringBuilder sb=new StringBuilder();
    byte buf[]=message.getBytes();
    byte[] md5=md.digest(buf);
    for (    byte aMd5 : md5) {
      String tmpStr="0" + Integer.toHexString((0xff & aMd5));
      sb.append(tmpStr.substring(tmpStr.length() - 2));
    }
    return sb.toString();
  }
 catch (  NoSuchAlgorithmException e) {
    return null;
  }
}

public static String md5 ( java . lang . String message ) { try { MessageDigest md = MessageDigest . getInstance ( "MD5" ) ; StringBuilder sb = new StringBuilder ( ) ; byte buf [ ] = message . getBytes ( ) ; byte [ ] md5 = md . digest ( buf ) ; for ( byte aMd5 : md5 ) { String tmpStr = "0" + Integer . toHexString ( ( 0xff & aMd5 ) ) ; sb . append ( tmpStr . substring ( tmpStr . length ( ) - 2 ) ) ; } return sb . toString ( ) ; } catch ( NoSuchAlgorithmException e ) { return null ; } }
creates an md5 digest from the message . note that this implementation is unsalted .
