Here you can find the source of md5(Object content)
public static String md5(Object content)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static final String CARTSET_UTF_8 = "UTF-8"; private static final String MD5_NAME = "MD5"; public static String md5(Object content) { String keys = null;//from ww w.j av a 2s.co m if (content == null) { return null; } try { MessageDigest md = MessageDigest.getInstance(MD5_NAME); byte[] bPass = String.valueOf(content).getBytes(CARTSET_UTF_8); md.update(bPass); keys = bytesToHexString(md.digest()); } catch (NoSuchAlgorithmException aex) { System.out.println(aex); } catch (java.io.UnsupportedEncodingException uex) { System.out.println(uex); } return keys.toLowerCase(); } private static String bytesToHexString(byte[] bArray) { StringBuffer sb = new StringBuffer(bArray.length); String sTemp; for (int i = 0; i < bArray.length; i++) { sTemp = Integer.toHexString(0xFF & bArray[i]); if (sTemp.length() < 2) { sb.append(0); } sb.append(sTemp.toUpperCase()); } return sb.toString(); } }