note 37633 deleted from function.md5 by vincent

From: Date: Fri, 21 Nov 2003 13:43:42 +0000
Subject: note 37633 deleted from function.md5 by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-60752@lists.php.net to get a copy of this message
Note Submitter: vidar@hokstad.com ---- To simms: You don't seem to understand what md5() does. md5() is a one way hash of what you pass in. So if you pass the same data in, you get the same md5() hash out, no matter how many times you call md5(). Otherwise md5() would be useless (it is intended to allow you to compare two items of data for equality with a reasonable certainty without access to the original data) So with your function, if two files are submitted with the same $originalName in the same time interval, they would get the same name, and no matter how many times you execute the loop that will still be the case. md5() is NOT suitable for generating unique file names. In fact, md5() the way you suggest using it will generate LESS unique file names than just using the original filename + date, as multiple strings map to the same MD5 hash (though, as you note, that is unlikely to happen in practice). The only reason what you suggest works is because it is a) unlikely two files will be submitted with the same name within one second, and b) it will at worst wait a second to get another name. But both of those will be true withouth using MD5 too.

« previous php.notes (#60752) next »