Here you can find the source of md5(String source, int bit)
public static String md5(String source, int bit) throws NoSuchAlgorithmException
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String md5(String source, int bit) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(source.getBytes());/*from w ww .j a va 2s . c om*/ 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)); } if (bit == 16) { return buf.substring(8, 24); } if (bit == 32) { return buf.toString(); } return null; } }