Here you can find the source of md5sum(String str)
public static String md5sum(String str)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String md5sum(String str) { try {/*w ww. j a v a2 s . c om*/ return md5sum(str.getBytes("UTF-8")); } catch (UnsupportedEncodingException uee) { return null; } } private static String md5sum(byte[] bytes) { String ret = null; try { MessageDigest md = MessageDigest.getInstance("md5"); byte[] byteDigest = md.digest(bytes); ret = byteToString(byteDigest); } catch (NoSuchAlgorithmException nsae) { nsae.printStackTrace(); } return ret; } private static String byteToString(byte[] digest) { String tmpStr = ""; StringBuffer strBuf = new StringBuffer(40); for (int i = 0; i < digest.length; i++) { tmpStr = (Integer.toHexString(digest[i] & 0xff)); if (tmpStr.length() == 1) { strBuf.append("0" + tmpStr); } else { strBuf.append(tmpStr); } } return strBuf.toString(); } }