Here you can find the source of md5Encrypt(String str)
public static String md5Encrypt(String str)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private final static String MD5_DIGEST = "MD5"; public static String md5Encrypt(String str) { if (str == null) return str; MessageDigest localMessageDigest = null; try {/*from ww w . j a va2 s . c om*/ localMessageDigest = MessageDigest.getInstance(MD5_DIGEST); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } localMessageDigest.update(str.getBytes()); byte[] arrayOfByte = localMessageDigest.digest(); return byte2Hex(arrayOfByte); } public static String byte2Hex(byte[] paramArrayOfByte) { String str1 = ""; String str2 = ""; for (int i = 0; i < paramArrayOfByte.length; i++) { str2 = Integer.toHexString(paramArrayOfByte[i] & 0xFF); if (str2.length() == 1) str1 = str1 + "0" + str2; else str1 = str1 + str2; } return str1.toLowerCase(); } }