Here you can find the source of MD5(String str)
public static String MD5(String str)
//package com.java2s; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String MD5(String str) { return MD5(str.getBytes()); }/*from ww w . j a v a 2 s . c o m*/ /** * MD5 encrypt method * @param msg original data * @return encrypt data */ public static String MD5(byte[] msg) { try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(msg); byte[] digest = md.digest(); StringBuffer buf = new StringBuffer(digest.length * 2); for (int i = 0; i < digest.length; i++) { int intVal = digest[i] & 0xff; if (intVal < 0x10) { buf.append("0"); } buf.append(Integer.toHexString(intVal)); } return buf.toString(); } catch (NoSuchAlgorithmException ne) { return null; } } }