I have a MD5 hash (for example "5d41402abc4b2a76b9719d911017c592") and I want to find another string that has the same hash. So far I have created two algorithms (one in Java and another in C#) but they run really slow. At the moment I can only process around 100,000 hashes per second. Are there any other algorithms I should use to speed things up?
This is an example of the algorithm I'm currently using in Java (I have the original hash stored in originalHash, then I generate hashes of other strings that are just numbers and compare the hashes):
import java.security.*;
import java.math.*;
public class b {
public static void main(String args[]) throws Exception{
String s="Hello";
MessageDigest m=MessageDigest.getInstance("MD5");
m.update(s.getBytes(),0,s.length());
String originalHash = new BigInteger(1,m.digest()).toString(16);
System.out.println("MD5: " + originalHash);
for (long i = 0; i < 9223372036854775807L; i++)
{
String iString = i + "";
m.update(iString.getBytes(),0,iString.length());
iString = new BigInteger(1,m.digest()).toString(16);
if (originalHash.equals(iString))
{
System.out.println("Found MD5: " + iString);
break;
}
if (i%1000000 == 0)
{
System.out.println("Count: " + (long)i/1000000 + "M");
System.out.println("Sample Hash: " + iString);
}
}
}
}
MD5Cngis faster thanMD5Managedin C#. Finally, if this is for actual hash breaking, oclHashcat will provide better performance than you'll ever get with Java.