-1

I am about to build a simple document system in php. I would like to know if "md5_file()" is "safe" comparison for all filetypes.

I don't know all filetypes in the system. But I need to be able to compare all types.

Is there any alternatives?

groyk
  • 43
  • 3
  • 1
    All the function does is read a file and create an `md5` hash of its contents. It would be similar to you doing `md5 /path/to/file` on the command line. It won't execute any files, nor will it write. – Justin Wood Feb 27 '14 at 20:45
  • 3
    "Safe" in what respect exactly? – deceze Feb 27 '14 at 20:47
  • With "safe" I am thinking i my application. If i am opening a file and make changes. What are the possibility that the md5 output will match the md5 from the old file. – groyk Feb 28 '14 at 22:04
  • Could you please mark an answer if it helped you in any way. – ek9 Mar 08 '14 at 23:10

2 Answers2

2

For functions like md5_file(), sha_file() it does not matter what the actual content (or filetype) of the file is.

ek9
  • 3,392
  • 5
  • 23
  • 34
0

sha1_file is an arguably "safer" calculation, but will also be slower.

Jack
  • 985
  • 7
  • 11