Here you can find the source of md5(String s)
public static String md5(String s)
//package com.java2s; import java.security.MessageDigest; public class Main { public static String md5(String s) { String retn = null;//from www. j a v a 2s .c o m if (null == s || s.length() < 1) { return retn; } try { MessageDigest md5 = MessageDigest.getInstance("MD5"); byte[] bytes = md5.digest(s.getBytes("UTF-8")); retn = toHexString(bytes); } catch (Exception e) { throw new RuntimeException(e); } return retn; } private static String toHexString(byte[] bytes) { StringBuilder retn = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { String hex = Integer.toHexString(bytes[i] & 0xFF); if (hex.length() == 1) { retn.append("0"); } retn.append(hex); } return retn.toString(); } }