Here you can find the source of MD5(String str)
public static String MD5(String str)
//package com.java2s; import java.security.MessageDigest; public class Main { public static String MD5(String str) { try {/*from w w w . ja va2s . c o m*/ if (isBlank(str)) { return null; } MessageDigest md = java.security.MessageDigest.getInstance("MD5"); md.update(str.getBytes("UTF-8")); byte tmp[] = md.digest(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 16; i++) { sb.append(String.format("%02x", tmp[i])); } return sb.toString(); } catch (Exception e) { return null; } } public static boolean isBlank(String str) { int length; if ((str == null) || ((length = str.length()) == 0)) { return true; } for (int i = 0; i < length; i++) { if (!Character.isWhitespace(str.charAt(i))) { return false; } } return true; } }