This function produces a one-way hash of a file. It works just like md5() but instead of feeding it a string, you give it a file name.

Refer to yesterday’s entry - md5() - for all the details. It all applies here. The raw_output paramater, the 32 character result, the rainbow tables, the collisions…

As you can see from the example below, the hash of the file and the hash of the filename string are different. This function uses the file’s contents. And the file can be of any type: php, html, mov, txt, etc…

$file     = "living/in/the/past.php";
$hash     = md5_file($file);       // 0b5f7cd8c85f64b2d2b31ae002bce7ef
$hash_str = md5($file);            // 93bc3c03503d8768cf7cc1e39ce16fcb
$hash_b   = md5_file($file, true); // ÕJò_{á\-Ñü?á·oò