public class Test{ private static final char[] x = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; static MessageDigest d; public static void main(String[] args) throws NoSuchAlgorithmException { d = MessageDigest.getInstance("MD5"); for(int i=0;i<10;i++){ loop(i+1,""); } // } private static void loop(int i,String s){ if(i>0){ for(int k=0;k<x.length;k++){ loop(i-1,s+x[k]); } }else{ // System.out.println(s+"!"); check(s); } } private static void check(String s){ d.reset(); String ta = s; d.update((ta).getBytes()); byte b[] = d.digest(); // System.out.println(bytesToHexStr(b)); if(bytesToHexStr(b).equals("F7A5C99C58103F6B65C451EFD0F81826")){ System.out.println(ta); } } private static String bytesToHexStr(byte[] bcd) { StringBuffer s = new StringBuffer(bcd.length * 2); for (int i = 0; i < bcd.length; i++) { s.append(bcdLookup[(bcd[i] >>> 4) & 0x0f]); s.append(bcdLookup[bcd[i] & 0x0f]); } return s.toString(); } private static final char[] bcdLookup = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; }