Here you can find the source of MD5Encode(String inStr)
public static String MD5Encode(String inStr) throws NoSuchAlgorithmException, UnsupportedEncodingException
//package com.java2s; //License from project: Artistic License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String MD5Encode(String inStr) throws NoSuchAlgorithmException, UnsupportedEncodingException { MessageDigest md = getMessageDigest("MD5"); return bytetoString(md.digest(inStr.getBytes("UTF-8"))); }/*w w w . jav a 2 s . co m*/ private static MessageDigest getMessageDigest(String digestType) { try { return MessageDigest.getInstance(digestType); } catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("No such algorithm [" + digestType + "]"); } } private static String bytetoString(byte[] digest) { StringBuffer sb = new StringBuffer(); String tempStr; for (int i = 0; i < digest.length; i++) { tempStr = (Integer.toHexString(digest[i] & 0xff)); if (tempStr.length() == 1) { sb.append("0" + tempStr); } else { sb.append(tempStr); } } return sb.toString().toLowerCase(); } }