Here you can find the source of md5(String encryptStr)
public static String md5(String encryptStr) throws Exception
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; public class Main { public static String md5(String encryptStr) throws Exception { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(encryptStr.getBytes("UTF-8")); byte[] digest = md.digest(); StringBuffer md5 = new StringBuffer(); for (int i = 0; i < digest.length; i++) { md5.append(Character.forDigit((digest[i] & 0xF0) >> 4, 16)); md5.append(Character.forDigit((digest[i] & 0xF), 16)); }/*w w w . ja va 2 s. c o m*/ encryptStr = md5.toString(); return encryptStr; } }