3 ms·
Ask HN: Can a result of (any) hash algorithm contain the hash result itself?
Suppose you have a file of 240 lines. Any lines, any content. You then calculate the hash of that file, let's say MD5, and the result is something in the following structure:
f8dbe310c1f61066d766071b07503ce8
Now, you take this hexadecimal digest, and add it to the file as line 241.
Rehashing the file (with additional hash line) will result with a new hash value obiously.
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 6y agoPossible yes - there are an infinite number of documents that match any given hash value. Can I construct one? Doubtful.
- bloak 6y agoPossible 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.