kind of extra security..
cheers
Richard Davey wrote:
Hello Guy,
Thursday, December 9, 2004, 11:39:27 AM, you wrote:
GB> $hash = md5(uniqid($message));
GB> where message is a string that the user will input.
GB> How likely is it that this hash might be repeated?
GB> I'm using the hash as a primary key in a database - the user gets sent GB> the hash as part of a url to retrieve the details of that database row.
GB> (its a basic send to a friend e-card system).
GB> Is there any way that the same hash could have been generated more than GB> once?
It's extremely unlikely (I cannot give you any stats as to how unlikely though, sorry).
However why not just stick the $hash creation into a self-checking loop. I.e. make the hash - check the database - does it exist already? - If not then the hash is good, else repeat the process. Using uniqid will give you a unique hash on each occasion so this process shouldn't take very long at all even if it did find a duplicate a few times (unlikely!)
Best regards,
Richard Davey
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php