Here you can find the source of md5(String text)
public static String md5(String text)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String md5(String text) { try {//from w w w . j av a2 s . c o m return hash("MD5", text); } catch (Exception e) { throw new RuntimeException(e); } } public static String hash(String algorithm, String text) throws NoSuchAlgorithmException { try { MessageDigest md = MessageDigest.getInstance(algorithm.toUpperCase()); byte[] hash = md.digest(text.getBytes("UTF-8")); StringBuilder sb = new StringBuilder(2 * hash.length); for (byte b : hash) { sb.append(String.format("%02x", b & 0xff)); } return sb.toString(); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } }