Here you can find the source of md5(String text)
public static String md5(String text) throws Exception
//package com.java2s; //License from project: Open Source License import java.security.*; public class Main { public static String md5(String text) throws Exception { return md5(text.getBytes("UTF-8")); }// w w w. j a v a 2 s . c om public static String md5(byte[] source) throws Exception { int bufferSize = 4096; byte[] buffer = new byte[4096]; MessageDigest md5 = MessageDigest.getInstance("MD5"); int remain = source.length; while (remain > 0) { int len = (remain > bufferSize) ? bufferSize : remain; System.arraycopy(source, source.length - remain, buffer, 0, len); remain = remain - len; md5.update(buffer, 0, len); } return byte2Hex(md5.digest()); } public static String byte2Hex(byte[] bytes) throws Exception { final String HEX = "0123456789abcdef"; String result = ""; for (int i = 0; i < bytes.length; i++) { result += HEX.charAt(bytes[i] >> 4 & 0x0F); result += HEX.charAt(bytes[i] & 0x0F); } return new String(result); } }