code: public static String md5(String s) {
  		if (s == null) {
  			return "";
  		}
  		try {
  			MessageDigest md = MessageDigest.getInstance("MD5");
  			md.update(s.getBytes());
  
  			byte[] byteData = md.digest();
  
  			//convert the byte to hex format method 1
  			StringBuilder sb = new StringBuilder();
  			for (int i = 0; i < byteData.length; i++) {
  				sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
  			}
  			return sb.toString();
  		} catch (NoSuchAlgorithmException ex) {
  			return "";
  		}
  	}
docs: md5 hash function.
  @param s the string to be hashed
  @return an md5 hash