Re: Use decent entropy for uniqid($prefix, TRUE)
| From: | Yasuo Ohgaki | Date: | Sun, 08 Jan 2017 20:31:26 +0000 |
| Subject: | Re: Use decent entropy for uniqid($prefix, TRUE) | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97594@lists.php.net to get a copy of this message | ||
Hi Kazuo,
On Mon, Jan 9, 2017 at 3:15 AM, Kazuo Oishi <kazuo@o-ishi.jp> wrote:
> No. Lauri's version is better.
>
> Your php_random_bytes_throw() version is significantly slow. Lauri's
> version is faster and cleaner.
>
> [original uniqid() using php_combined_lcg]
> $ time ./php_uniqid_orig -r 'for($i=0; $i<1000000;$i++)
> uniqid("",true);'
> real 0m0.366s
> user 0m0.350s
> sys 0m0.010s
>
> [your php_random_bytes_throw version (commit 48f1a17886d874dc90867c66948180
> 4de90509e8)]
> $ time ./php_uniqid_yohgaki -r 'for($i=0; $i<1000000;$i++)
> uniqid("",true);'
> real 0m4.509s
> user 0m0.430s
> sys 0m4.070s
>
> [Lauri's php_random_int version]
> $ time ./php_uniqid_lauri -r 'for($i=0; $i<1000000;$i++)
> uniqid("",true);'
> real 0m0.664s
> user 0m0.260s
> sys 0m0.400s
>
Interesting result. AFAIK, I didn't get significant difference when I made
the patch.
What is your system? It seems your PRNG is significantly slow.
BTW, my patch is extension in mind. i.e. Use of non numeric chars
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net