Here you can find the source of md5(String plainText)
public static String md5(String plainText)
//package com.java2s; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String md5(String plainText) { String encryptText = null; try {//ww w . jav a2 s . co m MessageDigest m = MessageDigest.getInstance("MD5"); m.update(plainText.getBytes("UTF8")); byte s[] = m.digest(); StringBuilder result = new StringBuilder(); for (int i = 0; i < s.length; i++) { result.append(Integer.toHexString((0x000000FF & s[i]) | 0xFFFFFF00).substring(6)); } encryptText = result.toString(); } catch (Exception e) { e.printStackTrace(); } return encryptText; } public static String MD5(String plainText) { try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(plainText.getBytes()); byte b[] = md.digest(); int i; StringBuffer buf = new StringBuffer(""); for (int offset = 0; offset < b.length; offset++) { i = b[offset]; if (i < 0) i += 256; if (i < 16) buf.append("0"); buf.append(Integer.toHexString(i)); } return buf.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; } }