0

I've got a php test that generates an output file and compares it with a sample one previuosly generated. I make the comparison by using the php function "md5_file" with both files. My problem is that even though both files have the exact same contents, the md5 function outputs different values (I have also tryed with sha1_file with the same results). In addition, I've compared with vimdiff both files for making sure that they're the same. Also it fails the comparison whe i manually copy the file contents from one file to the other.

My problem occurs on a machine running ubuntu 12.x, and the file is shared by git.

I have the impression that it might be a line ending problem, but I don't know how to be sure about it.

Cœur
  • 37,241
  • 25
  • 195
  • 267
marcelo
  • 23
  • 3
  • if md5 gives different hashes, then the files are different. they may LOOK identical to you, but they obviously aren't. Even something as simple as an extra space or line break at the end of the file will completely change the hash value (as it should). – Marc B Apr 01 '15 at 19:03
  • A trailing whitespace or `"\r\n"`/`"\n"` differences... but you'd have to do an actual line-by-line check to eliminate those – Mark Baker Apr 01 '15 at 19:03
  • Even a BOM will make it different. – AbraCadaver Apr 01 '15 at 19:15

1 Answers1

0

Try to echo the urlencode value of those files, it should be able to show differ of end lines.

Jafar Akhondali
  • 1,552
  • 1
  • 11
  • 25