Here you can find the source of md5(String s)
public static String md5(String s)
//package com.java2s; //License from project: LGPL import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static final int BYTE_MASK = 0xFF; public static String md5(String s) { try {//from ww w . j av a 2s.com return md5(s.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return ""; } } public static String md5(byte[] data) { try { // Create MD5 Hash MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); digest.update(data); byte messageDigest[] = digest.digest(); // Create Hex String StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { String s = Integer.toHexString(BYTE_MASK & messageDigest[i]); if (s.length() < 2) s = "0" + s; hexString.append(s); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return ""; } }