Here you can find the source of md5Hash(String content)
public static String md5Hash(String content)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String md5Hash(String content) { byte[] bytesOfMessage = null; byte[] theDigest = null; try {/*from w w w.java 2 s .c om*/ bytesOfMessage = content.getBytes("UTF-8"); MessageDigest md = MessageDigest.getInstance("MD5"); theDigest = md.digest(bytesOfMessage); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return theDigest == null ? null : convertDigestToString(theDigest); } private static String convertDigestToString(byte[] digest) { StringBuffer result = new StringBuffer(); for (int i = 0; i < digest.length; i++) { result.append(Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1)); } return result.toString(); } }