0

I'm trying to generate a file full of data with an MD5 hash that matches the hash of some password string.

Because I don't care exactly what the string is, I figure that this is second-preimage, and should be possible.

i.e. "yellowpotato350" -> ae65242af3d29c2a412fc2e444fc7eb3, which is also the hash of some data file.

I don't really care what the exact string is, but I'd like it to be "passwordy", i.e. dictionary words & numbers, maybe some leetspeak, but not just a completely random string.

2
  • I know MD5 has a collision issue, but I don't know if this is possible. Here is a question on the crypto stack that might point you in the right direction. Best of luck.
    – INV3NT3D
    Commented Feb 8, 2017 at 16:26
  • It's fairly broken, but there haven't been any examples which are that clear - tends to be shortish hex strings, or longish arbitrary binary files, rather than password type strings. Doesn't mean they don't exist, but most collisions are generated by bolting crafted bits onto files.
    – Matthew
    Commented Feb 8, 2017 at 16:35

2 Answers 2

0

This isn't possible in the way I think you think this is possible, unfortunately. MD5 (along with most hashing algorithms) are made so a unique string of data results in a unique hash. For example, a simple plain-text file with data inside of it will never have the same hash as the password "yellowpotato350". This is intentional because, as an example, you wouldn't want attackers to be able to authenticate to someone's account with a different password (or file).

The caveat is that MD5 has collision issues, where, sometimes, two different sets of data can produce the same hash. For example, the word "test" and "not a test" may produce the same hash (they don't in the real-world, but just as an example). The big piece here is "sometimes", in that you won't be able to reliably identify collisions like this between passwords and files that would be anywhere close to efficient.

Without knowing your specific use-case, if you want to use files in a way to validate strings/passwords, your best bet would be to store the hash in a file then read the hash to validate the string/password.

0

MD5 creates a 128 bit hash. If you generated 2^64 files, and 2^64 passwords, then you would likely find a collision, that is one of those 2^64 files has the same hash as one of the 2^64 passwords.

But if you have just one file with one hash, then you’d need 2^128 passwords to have a good chance that one password has a matching hash.

There are ways to find MD5 collisions a bit faster. That would be relevant if the NSA is willing to spend tons of money to fine a file and a password with the same hash; I can’t and nor can you. And finding one password with the same hash as one specific file is basically impossible.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .