Of course I know is possible to create a file with a certain size and how to do it. But is it possible to create a file with a certain size and also a certain MD5 fingerprint?
It is possible to create a file given a hash value. However, if you have a file and create a MD5 hash this process will not recreate that file but create a small file filled with gibberish.
The hash size for the MD5 algorithm is 128 bits. The ComputeHash methods of the MD5 class return the hash as an array of 16 bytes. Note that some MD5 implementations produce a 32-character, hexadecimal-formatted hash.
Could it be changed? No. You can not change md5sum of a file as long as the contents of the files are same. And that is the sole purpose of it.
Not being able to find a file with a certain hash is one of the defining properties of a cryptographic hash function such as md5.
While md5 has been broken, those breaks only allow you to create two different files (images) with the same hash, but not with a predetermined hash.
What you want is called a pre-image attack, and since md5 is still unbroken concerning that attack, you need to bruteforce.
This requires 264 (2128/2) hashing operations on average, which is far beyond anything we can get with current computers.
Wikipedia has an article on pre-image attacks too:
http://en.wikipedia.org/wiki/Preimage_attack
Just creating a file with a given MD5 hash is difficult enough without adding the size requirement.
You could try a rainbow table, but that requires a long time to create and a huge amount of memory to store.
Theoretically, yes. Practically, it will most likely require computation of all permutations of all n bytes in a file -- baiscally, brute-forcing. Which means, this is hardly doable in any reasonable timeframe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With