note 37633 added to function.md5

From: Date: Fri, 21 Nov 2003 12:58:57 +0000
Subject: note 37633 added to function.md5
Groups: php.notes 
Request: Send a blank email to php-notes+get-60751@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.md5.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37633 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37633&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37633&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60751) next »