Here you can find the source of MD5(String str)
public static String MD5(String str)
//package com.java2s; //License from project: Artistic License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String MD5(String str) { return encrypt(str, "MD5"); }// ww w . j av a2 s . c o m public static String encrypt(String str, String enc) { MessageDigest md = null; String result = null; byte[] bt = str.getBytes(); try { md = MessageDigest.getInstance(enc); md.update(bt); result = bytes2Hex(md.digest()); } catch (NoSuchAlgorithmException e) { return null; } return result; } private static String bytes2Hex(byte[] bts) { String des = ""; String tmp = null; for (byte bt : bts) { tmp = (Integer.toHexString(bt & 0xFF)); if (tmp.length() == 1) { des += "0"; } des += tmp; } return des; } }