Here you can find the source of md5(String inputText)
public static String md5(String inputText)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String md5(String inputText) { if (inputText == null || "".equals(inputText.trim())) { throw new IllegalArgumentException("please input un-null value"); }// www.j a v a 2 s .c o m String encryptText = null; try { MessageDigest m = MessageDigest.getInstance("md5"); m.update(inputText.getBytes()); byte s[] = m.digest(); return hex(s); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return "" + inputText.hashCode(); } } private static String hex(byte[] arr) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < arr.length; ++i) { sb.append(Integer.toHexString((arr[i] & 0xFF) | 0x100).substring(1, 3)); } return sb.toString(); } }