Here you can find the source of md5(String d)
public static String md5(String d)
//package com.java2s; /*//w w w . j a va 2s . c o m * Copyright (C) ${year} Omry Yadan <${email}> * All rights reserved. * * See https://github.com/omry/banana/blob/master/BSD-LICENSE for licensing information */ import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; public class Main { public static String md5(String d) { return md5(d.getBytes()); } public static String md5(byte[] b) { try { MessageDigest m = MessageDigest.getInstance("MD5"); m.reset(); m.update(b); byte[] digest = m.digest(); BigInteger bigInt = new BigInteger(1, digest); String hashtext = bigInt.toString(16); // Now we need to zero pad it if you actually want the full 32 // chars. while (hashtext.length() < 32) { hashtext = "0" + hashtext; } return hashtext; } catch (NoSuchAlgorithmException nsae) { return "ERROR"; } } public static String toString(Collection<String> list) { return toString(list.toArray(new String[list.size()])); } public static String toString(Object array[]) { return toString(array, ","); } public static String toString(int array[]) { return toString(array, ","); } public static String toString(long array[]) { return toString(array, ","); } public static String toString(double[] array) { return toString(array, ","); } public static String toString(Object array[], String sep) { return toString(array, sep, 0, array.length); } public static String toString(Object array[], String sep, int start, int end) { StringBuffer sb = new StringBuffer(); for (int i = start; i < end; i++) { if (i > start) sb.append(sep); sb.append(array[i]); } return sb.toString(); } public static String toString(long array[], String sep) { return toString(array, sep, 0, array.length); } public static String toString(double array[], String sep) { return toString(array, sep, 0, array.length); } public static String toString(int array[], String sep) { return toString(array, sep, 0, array.length); } public static String toString(double array[], String sep, int start, int end) { StringBuffer sb = new StringBuffer(); for (int i = start; i < end; i++) { if (i > 0) sb.append(sep); sb.append(array[i]); } return sb.toString(); } public static String toString(long array[], String sep, int start, int end) { StringBuffer sb = new StringBuffer(); for (int i = start; i < end; i++) { if (i > 0) sb.append(sep); sb.append(array[i]); } return sb.toString(); } public static String toString(int array[], String sep, int start, int end) { StringBuffer sb = new StringBuffer(); for (int i = start; i < end; i++) { if (i > 0) sb.append(sep); sb.append(array[i]); } return sb.toString(); } }