RE: [PHP] Random string
| From: | Jason Wong | Date: | Mon, 18 Sep 2000 02:10:51 +0000 |
| Subject: | RE: [PHP] Random string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-17120@lists.php.net to get a copy of this message | ||
It really depends on how many of these strings you need. If you have an 8
character string consisting only of alphanumerics then there would be
62^8 permutations, which is about 2.2E14. So say you wanted to produce 1
million of these things the chances of any two of them being the same
would be 2.2E8.
-
Jason Wong
Digital View Ltd
2201 Nanyang Plaza
57 Hung To Road
Kwun Tong
HONG KONG
Tel: +852-2861-3615
Fax: +852-2520-2987
www.digitalview.com
> -----Original Message-----
> From: n e t b r a i n [mailto:net-brain@net-brain.net]
> Sent: 16 September 2000 01:24
> To: Jason Wong
> Subject: R: [PHP] Random string
>
>
> Hi Jason,
>
> > Here's something that I've used:
> >
> > $new_password = substr(md5(uniqid(rand())), 0, 8);
>
> Well, this was the first idea which has come to my mind, but
> ... if about
> md5(uniqid(rand())) I'm quite sure that is a safe & unique
> string 32 chars
> long, can I say the same if I trunk it in brutal way with
> substr()? Is it
> real a unique string?
>
> Suggestion are very welcome
> max
>