0

I have two simple PHP scripts: testHash.php and me.php. The testHash.php is simply doing a md5_file function to the me.php and printing out the result

testHash.php contains:

<?php 
 $test = md5_file(__DIR__."/me.php"); 
 echo $test;
 echo phpinfo();
?>

and me.php contains:

<?php
echo "Hello World";
?>

I have uploaded both script to two different Webserver using an FTP Tool (FileZilla) without of course touching the files. One is a local virtual machine and the other is a public Webserver.The output of the $test variable was different from the other. Both webserver operates on LAMP framework

  1. Local VM Webserver = 7633bbfa20ed2d29a55338913048eff0
  2. Public Webserver = 3a65329165abe28a485bed663da5e298

Why are they different from each other? Are there external factors (framework, PHP Versions, PHP configuration files) which affects the computation of the hash. Thank You.

Stephan Vierkant
  • 9,674
  • 8
  • 61
  • 97
tangol100
  • 21
  • 4

1 Answers1

4

The md5's are different if the files are.

If you're transfering your file in ascii-mode, something in them could change, like the line endings changing from CRLF to LF.

  • Thanks so much. Il keep in mind the mode of transfer of my FTP tool. In my FileZilla->Transfer->Transfer Transfer Type was set to auto. I just set it to Binary. Thanks a lot – tangol100 Jan 22 '15 at 08:55