Here you can find the source of md5(String s)
public static String md5(String s)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static MessageDigest digest; public static String md5(String s) { try {/* w ww .java 2s. c om*/ MessageDigest md = MessageDigest.getInstance("MD5"); byte[] messageDigest = md.digest(s.getBytes("UTF-8")); BigInteger number = new BigInteger(1, messageDigest); String md5 = number.toString(16); while (md5.length() < 32) md5 = "0" + md5; return md5; } catch (NoSuchAlgorithmException e) { //TODO error handle } catch (UnsupportedEncodingException e) { //TODO error handle } return null; } }