Page 1 of 1
md5()
Posted: Fri Apr 27, 2007 1:49 pm
by guitarlvr
If you run the md5() function on a file, will it return a unique 32 bit hash for that file or is there a posibility that it would be the same if you edited the same file and added a space, let alone a completely different file?
Wayne
Posted: Fri Apr 27, 2007 2:01 pm
by John Cartwright
If you change anything within the file it will return a different hash, and you should be using
md5_file() for files
Posted: Fri Apr 27, 2007 2:02 pm
by guitarlvr
Thats exactly what i need. Thanks.
Wayne
Posted: Fri Apr 27, 2007 2:07 pm
by onion2k
Jcart is wrong. There is a chance that an md5 hash could be the same for two distinct files. It's incredibly unlikely of course, but it is possible.
Posted: Fri Apr 27, 2007 2:08 pm
by John Cartwright
I never said there isn't a chance for a collision

, although I worded my reply kind of weird so I understand why you would "correct me"
Posted: Fri Apr 27, 2007 2:10 pm
by guitarlvr
if two files were exactly the same they would return the same hash, correct?
Wayne
Posted: Fri Apr 27, 2007 2:11 pm
by John Cartwright
Try it.
Posted: Fri Apr 27, 2007 2:12 pm
by onion2k
Jcart wrote:I never said there isn't a chance for a collision

, although I worded my reply kind of weird so I understand why you would "correct me"
You said: "If you change anything within the file it will return a different hash". That's not true. There is a very, very small chance that it will return the same hash.