Here you can find the source of md5Encode(String message)
public static String md5Encode(String message)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static final boolean toUpperCase = true; public static String md5Encode(String message) { return encode("MD5", message); }//from w w w . j av a 2 s.c o m private static String encode(String code, String message) { return encode(code, message.getBytes()); } private static String encode(String code, byte[] message) { MessageDigest md; String encode = null; try { md = MessageDigest.getInstance(code); encode = byteArrayToHexString(md.digest(message)); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return encode; } private static String byteArrayToHexString(byte[] digest) { StringBuffer md5StrBuff = new StringBuffer(); for (int i = 0; i < digest.length; i++) { if (Integer.toHexString(0xFF & digest[i]).length() == 1) { md5StrBuff.append("0").append(Integer.toHexString(0xFF & digest[i])); } else { String hex = Integer.toHexString(0xFF & digest[i]); if (toUpperCase) { hex = hex.toUpperCase(); } md5StrBuff.append(hex); } } return md5StrBuff.toString(); } }