A way for a file to have its own MD5 inside? Or a string that is it's own MD5?

Posted by Eli on Stack Overflow See other posts from Stack Overflow or by Eli
Published on 2010-04-05T18:19:58Z Indexed on 2010/04/06 1:43 UTC
Read the original article Hit count: 374

Filed under:
|
|

Hi all,

In considering several possible solutions to a recent task, I found myself considering how to get a php file that includes it's own MD5 hash. I ended up doing something else, but the question stayed with me.

Something along the lines of:

<?php
echo("Hello, my MD5 is [MD5 OF THIS FILE HERE]");
?>

Whatever placeholder you have in the file, the second you take its MD5 and insert it, you've changed it, which changes it's MD5, etc.

Edit:

Perhaps I should rephrase my question:

Does anyone know if it has been proven impossible, or if there has been any research on an algorithm that would result in a file containing it's own MD5 (or other hash)?

I suppose if the MD5 was the only content in the file, then the problem can be restated as how to find a string that is it's own MD5.

It may well be impossible for us to create a process that will result in such a thing, but I can't think of any reason the solution itself can't exist.

The question is basically whether it really is impossible, simply improbable (on the order of monkeys randomly typing Shakespeare), or actually solvable by somebody smarter than myself.

© Stack Overflow or respective owner

Related posts about md5

Related posts about encryption