Here you can find the source of byteMd5(String plainText, Boolean is16)
public static String byteMd5(String plainText, Boolean is16)
//package com.java2s; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String byteMd5(String plainText, Boolean is16) { StringBuffer buf = new StringBuffer(); try {//from ww w. jav a 2s. co m MessageDigest md = MessageDigest.getInstance("MD5"); md.update(plainText.getBytes()); byte b[] = md.digest(); int i; 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)); } } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return is16 ? buf.toString().substring(8, 24) : buf.toString(); } }