# Attack MD5 with partial information?

If I generate an MD5 hash from 2 pieces of information – i.e. by concatenating two strings – how easy is it to guess what that hash is, assuming an attacker has knowledge of only 1 piece of those info?

• How hard is it to guess the missing piece? – zaph Apr 30 '18 at 12:57
• – e-sushi Apr 30 '18 at 13:53

It all boils down to the amount of entropy in the second string.

How is that second string generated?

If a human generates it, you can be pretty sure that most of the time it will be easy to figure it out. If a computer generates it using a cryptographically strong random number generator, and the string has sufficient length (say more than 80 bits), it will not be feasible for an attacker to guess it.

string1 = "crypto";
string2 = "graphy";

stringToHash = string1 + string2;


MD5-hash of "cryptography": e0d00b9f337d357c6faa2f8ceae4a60d

If the attacker knew either string1 or string2, it would certainly be easier to brute-force it, since you know partial info of the hashed string and therefore you have to try less possibilities.

How much easier would it be?

If we allow the typical upper/lower case letters and digits/symbols, that gives us a set of (26 letters + 10 digits) * 2 cases = 72 characters.

cryptography has 12 letters, so it has 72^12 (19'408'409'961'765'342'806'016) possibilities. But since you know string1 or string2 it reduces the possibilities by that length.

So, i.e. the attacker knows that your input begins with "crypto" (and knows that the full input has 12 characters): Instead of 72^12, the possibilities now are 72^6.

• Just wondering about the use of an APOSTROPHE to separate numeric groups, is this a convention of a language or geographic area? Just that I have never seem that before. – zaph Apr 30 '18 at 13:28
• It was even easier if the missing piece is a word or password like. There are lists of words and passwords ordered by frequency of use. Interestingly as in they answer breaking a single word into pieces should increase the difficulty of a dictionary attack–except in an instance there the two pieces are each words in their own right. – zaph Apr 30 '18 at 13:36
• "you know partial info of the hashed string and therefore you have to try less possibilities." Is this generally true? How would you know that the missing piece is a six character alphanumeric string and not two megabytes of random data? – that other guy Apr 30 '18 at 18:12