Re: Re: [RFC][DISCUSSION] Improve uniqid() uniqueness
| From: | Yasuo Ohgaki | Date: | Tue, 04 Oct 2016 01:39:30 +0000 |
| Subject: | Re: Re: [RFC][DISCUSSION] Improve uniqid() uniqueness | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-96202@lists.php.net to get a copy of this message | ||
Hi Leigh,
On Mon, Oct 3, 2016 at 9:06 PM, Leigh <leight@gmail.com> wrote:
> I'm curious, did you consider using random_int? It already handles
> biasing, and you can reduce the repeated calls to random_bytes.
Yes. It seemed it might be slower due to number of retries at first,
but I realized that it isn't later.
It could be something like
$entropy = random_int(10000000000, 9999999999);
$entropy[1] = '.';
$uniqid = timestamp . $entropy;
I don't have particular preference.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net