
Ask HN: Can a result of (any) hash algorithm contain the hash result itself? - tzury
Suppose you have a file of 240 lines. Any lines, any content. You then calculate the hash of that file, let&#x27;s say MD5, and the result is something in the following structure:<p><pre><code>    f8dbe310c1f61066d766071b07503ce8
</code></pre>
Now, you take this hexadecimal digest, and add it to the file as line 241.<p>Rehashing the file (with additional hash line) will result with a new hash value obiously.<p>My questoin is whether it is even theoretically possible for a hash value to contain itself, meaning, can there be a file, with some content that its hashed value is identical to a string already presented in the file (e.g. line 241 in this example)
======
sloaken
Possible yes - there are an infinite number of documents that match any given
hash value.

Can I construct one? Doubtful.

~~~
bloak
Possible yes? It's a definite yes. Enumerate all possible hash values into a
single very big file. I think that even counts as "construct", in a
mathematical sense.

