Here you can find the source of md5(String text)
public static String md5(String text)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String md5(String text) { MessageDigest md = null;// w w w.ja va 2 s. c o m String outStr = null; try { md = MessageDigest.getInstance("MD5"); byte[] digest = md.digest(text.getBytes()); outStr = bytes2hex(digest); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } return outStr; } public static String bytes2hex(byte[] bytes) { StringBuilder hex = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { byte b = bytes[i]; boolean negative = false; if (b < 0) negative = true; int bAbs = Math.abs(b); if (negative) bAbs = bAbs | 0x80; String temp = Integer.toHexString(bAbs & 0xFF); if (temp.length() == 1) { hex.append("0"); } hex.append(temp.toLowerCase()); } return hex.toString(); } }