4
$\begingroup$

Are there any hash outputs not produced by the MD5 hash function? I need to use it as a placeholder for an empty hash while comparing two hashes.

$\endgroup$
  • $\begingroup$ Beware of magic values in general. If possible, design your programs in such a way that you don't need placeholders. If you use it you could also use the ASCII encoding of "this=placeholder", it's equally unlikely to generate that value as all zero's. $\endgroup$ – Maarten - reinstate Monica Nov 13 '15 at 18:27
5
$\begingroup$

Not provably. Maybe, since it's not a permutation, but you couldn't verify it practically.

Just use all-zeroes: it's easily recognizable as a null value, and thanks to pre-image resistance, no-one knows what hashes to that.

$\endgroup$
  • 1
    $\begingroup$ Because of the infinite input possibilities and since the structure is not likely to exclude values, I'd say that the chance that all outputs cannot be produced is extremely unlikely. It's likewise extremely unlikely that you'd ever generate a hash containing of all zero's by chance, even if it is rather certain that it exists. $\endgroup$ – Maarten - reinstate Monica Nov 13 '15 at 18:26
  • $\begingroup$ @MaartenBodewes I agree. $\endgroup$ – Reid Rankin Nov 14 '15 at 9:42
  • $\begingroup$ I will try to avoid it, but thank you! $\endgroup$ – kpriya Nov 14 '15 at 17:34
  • 3
    $\begingroup$ @MaartenBodewes, since the possible outputs are really a property of the compression function, there are not nearly infinite inputs. The compression function takes 640 bits of input and produces 128 bits of output so for a random function of that size the probability of some output missing is about $2^{-384}$ if my mental math works. $\endgroup$ – otus Nov 14 '15 at 22:11
  • $\begingroup$ @otus True enough, I stand corrected. My estimate is off by $2^{-384}$. Sheesh, crypto is a tough place ;) $\endgroup$ – Maarten - reinstate Monica Nov 14 '15 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.