Re: FW: [PHP] Unique random string

From: Date: Wed, 28 Jun 2000 11:42:42 +0000
Subject: Re: FW: [PHP] Unique random string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3536@lists.php.net to get a copy of this message
Hiya use microtime and add some random letters/numerics to it to fit into the 15 chars the uniqness will be the total random letters you can make(add) on the microsecond Greetz, Wico At 07:26 28-6-2000 -0400, Dan wrote:
Why not just have an integer that gets incremented. Represent it as a 14 digit hex number. Use the 15th digit as a prefix for the year.. 1AAAAAAAAAAA is year one, 2AAAAAAAA is the second year, and so on. If you need to check them against previous strings, build a table for that year of only the IDs you've generated with '1', the next year '2', etc. It should be a small subset of all of your random IDs. Dan Sevush CTO Dan's Chocolates Happy PHP site since 11/99 www.danschocolates.com -----Original Message----- From: William Ahern [mailto:wahern@mailshell.com] Sent: Tuesday, June 27, 2000 7:35 PM To: php-general@lists.php.net Subject: [PHP] Unique random string Any ideas on how I can generate a 'guaranteed' unique ascii string less than 15 characters. It must be guaranteed unique across several independent servers. Currently we are generating random short strings to create unique aliases for email addresses. The only problem is that to guarantee uniqueness we keep a log of previous strings and check to make sure we don't create duplicates (we cannot rotate strings. They must be absolutely unqiue for the next decade or so). The optimal solution would be to generate strings that are truly unique and hopefully random enough, w/o having to go through the process of checking for duplicates. I'd use uniqid(), except that it is 32 characters (too long since users will have to handle them sometimes) and the algorithm must be available to C, C++, Perl, whatever. Any comments, suggestions or answers! ;) would be great. Please add my address to the reply as I am not subscribed to the list. TIA, Bill -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.general (#3536) next »