On 4 October 2016 at 02:39, Yasuo Ohgaki <yohg...@ohgaki.net> wrote:
> Hi Leigh,
>
> On Mon, Oct 3, 2016 at 9:06 PM, Leigh <lei...@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
> yohg...@ohgaki.net

Since we want to preserve BC

entropy = random_int(0, 99999999);
uniqid = strpprintf(0, "%s%08x%05x.%08d", prefix, sec, usec, entropy);

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to