Here you can find the source of md5Hex(String str)
public static String md5Hex(String str)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static final char[] hexDigits = "0123456789abcdef" .toCharArray();/*ww w . j a v a 2 s .c o m*/ public static String md5Hex(String str) { final byte[] digested = md5(str); if (digested == null) return ""; return toHex(digested); } public static byte[] md5(String str) { try { MessageDigest digest = MessageDigest.getInstance("md5"); byte[] digested = digest.digest(str.getBytes()); return digested; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return null; } } public static final String toHex(byte[] bytes) { StringBuilder sb = new StringBuilder(2 * bytes.length); for (byte b : bytes) { sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]); } return sb.toString(); } }