Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102110 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32435 invoked from network); 13 May 2018 00:03:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2018 00:03:10 -0000 Authentication-Results: pb1.pair.com header.from=alice@librelamp.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=alice@librelamp.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain librelamp.com designates 45.79.96.192 as permitted sender) X-PHP-List-Original-Sender: alice@librelamp.com X-Host-Fingerprint: 45.79.96.192 librelamp.com Received: from [45.79.96.192] ([45.79.96.192:38356] helo=librelamp.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F8/80-28281-DB087FA5 for ; Sat, 12 May 2018 20:03:09 -0400 Received: from localhost.localdomain (92.sub-174-215-7.myvzw.com [174.215.7.92]) by librelamp.com (Postfix) with ESMTPSA id A3F011144; Sun, 13 May 2018 00:03:06 +0000 (UTC) To: Yasuo Ohgaki References: Cc: PHP internals Message-ID: Date: Sat, 12 May 2018 17:03:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Deprecation of uniqid() From: alice@librelamp.com (Alice Wonder) On 05/12/2018 03:46 PM, Yasuo Ohgaki wrote: > On Fri, May 11, 2018 at 9:34 PM, Alice Wonder > wrote: > > slightly better if block > > if($more_entropy) { > sodium_increment($nonce); > $x = hexdec(substr(bin2hex($nonce),0,12)); > $return = $return . substr($x, 2, 1) . '.' . substr($x, -8); > } > > Obvious patterns in the "more entropy" but the output in only > suppose to be unique, not random. > > > The most important issue in current uniqid() is it could have duplicate > even with $more_entropy=true, since it has > > + > > structure. > System time could be adjusted backwards by ntp, etc. > > However changing output by default as follows is enough for it. > > + + random though is expensive if you have to create many at a time, using an increment when called multiple times on same page requests results in pattern but is less expensive. So if predictable is okay that's better IMHO and often predictable (with a pattern) is okay. random based on time isn't necessary.