Robert Cummings schreef: > On Wed, 2008-12-17 at 02:03 +0100, Jochem Maas wrote: >> or just: >> >> mysql_query("UPDATE test SET mykey=UUID()"); >> >> can't see any reason to go down the 'loop the dataset and roll your >> own much less random, much more likely to collide, unique value' road. > > Not terribly random: > > 7e55a4d0-1d31-102c-8104-001fd05507bc > 7e8e9ed4-1d31-102c-8104-001fd05507bc > 7ec56be4-1d31-102c-8104-001fd05507bc > 7efbb50a-1d31-102c-8104-001fd05507bc > 7f339bf0-1d31-102c-8104-001fd05507bc > > But it's about as good as what has already come up :) I haven't come > accross UUID() before. It looks time based to me. it is, amongst other things. ands no it doesn't look very random, but it's garanteed (in your lifetime) to be unique even when you make the call simultaneous on any number of machines. I guess you could do better by doing something more complex than the single query I suggested ... but the first 8 chars are pretty much random enough to avoid simple (or even complex) guess work ... they're more random than the passwords most people use to log into 'whatever'. :-) my point was more that it's a bit silly to go about creating reams of code to generate random strings when there are prebuilt functions in the various tools we use written by people much cleverer than us (well me anyway) ... i.e. Leverage (siedenote: enjoyable TV show) the work of some crypto wizard and write a single LOC rather than create stacks of code you have to maintain which is probably not as good as the pre-built 'wheels'. that said UUID() is an interesting thing in it's own right, worthy of investigation. > >> sometimes less is more (although oddly more is never less ;-) > > What about when more is black holes? hmm. I guess that would depend on which side of the event horizon you were at. :-) > Cheers, > Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php