Question

Is it possible to generate a text file, the content of which is the file's hash/md5 value.

How to write the program?

Was it helpful?

Solution

If such a file exists, it is possible to generate it by trying every possible MD5 hash and checking if its MD5 hash equals it. But since all possible MD5 hashes are a finite set, such a special MD5 value might not even exist at all.

Note: you asked only if it's possible, not how much time it would take.

OTHER TIPS

I was interested too, so i wrote following pascal program:

program hash;

uses md5;

var a, b: string;

begin

b:='d41d8cd98f00b204e9800998ecf8427e'; //md5sum of /dev/null

repeat

a:=md5Print(md5String(b));
b:=md5Print(md5String(a));

until a=b;

writeln(a);
writeln(b);

end.

It running for about five days already, but still no result yet)))

Note that if you wish to brute force it, trimethoxy's approach is fundamentally flawed. Each hash effectively points to another random hash, and as the series of hashes increases, it becomes increasingly more likely that any newly visited hash will simply point you back to a previously visited hash, forming a cycle millions or billions of hashes long.

If we assume that the entire hash space of MD5 is not a single cyclical loop, which is exceedingly unlikely, then nearly all values are in a competitively short cyclical loop that leaves the vast majority of MD5 hashes unvisited.

Basically, even if self mapped hashes exist, that approach is still more likely to simply put itself in an infinite loop than it is to actually find one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top