Here you can find the source of md5Encrypt(String str)
public static String md5Encrypt(String str)
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; public class Main { static MessageDigest m_md5; public static String md5Encrypt(String str) { byte[] bytes = null; try {// w w w . ja va 2 s.c o m bytes = str.getBytes("UTF-8"); } catch (Exception e) { bytes = str.getBytes(); } byte messageDigest[] = null; synchronized (m_md5) { m_md5.update(bytes); messageDigest = m_md5.digest(); } StringBuffer hexString = new StringBuffer(); int d; for (int i = 0; i < messageDigest.length; i++) { d = messageDigest[i]; if (d < 0) d += 256; if (d < 16) hexString.append("0"); hexString.append(Integer.toHexString(d)); } return hexString.toString(); } }