Here you can find the source of md5(String input)
public static String md5(String input)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static final String ENCRY_MD5 = "md5"; public static String md5(String input) { return encrypt(input, ENCRY_MD5); }//from w w w .ja va 2s . c om public static String encrypt(String input, String... algorithms) { String algorithm = ENCRY_MD5; if (input == null || "".equals(input.trim())) { throw new IllegalArgumentException("Please input the encrypted content !"); } if (algorithms.length > 0) { algorithm = algorithms[0]; } byte[] bytes = null; try { MessageDigest md = MessageDigest.getInstance(algorithm); md.update(input.getBytes("UTF8")); bytes = md.digest(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return byte2hex(bytes); } private static String byte2hex(byte[] bytes) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < bytes.length; ++i) { sb.append(Integer.toHexString((bytes[i] & 0xFF) | 0x100).substring(1, 3)); } return sb.toString(); } }