Re: Unique random string
| From: | Chris Adams | Date: | Wed, 28 Jun 2000 01:15:55 +0000 |
| Subject: | Re: Unique random string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3487@lists.php.net to get a copy of this message | ||
> At 04:34 PM 6/27/00 -0700, William Ahern wrote:
> >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.
>
> There's the killer requirement.
md5($SERVER_IP . microtime() . $username_or_some_other_user_specific_data . srand(1,5000))
Unfortunately, md() produces a 32 character alphanumeric (a-z0-9) hash, so you'd need to
translate
that to use additional characters to reduce the overall length. Just using the uppercase alphabet as
well would suffice.