Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96212 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29483 invoked from network); 4 Oct 2016 10:07:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2016 10:07:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=leight@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=leight@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.45 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 209.85.218.45 mail-oi0-f45.google.com Received: from [209.85.218.45] ([209.85.218.45:35992] helo=mail-oi0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3E/0E-06241-85F73F75 for ; Tue, 04 Oct 2016 06:07:21 -0400 Received: by mail-oi0-f45.google.com with SMTP id m72so58878968oik.3 for ; Tue, 04 Oct 2016 03:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=2lq4K6S9wCit74ByAJsSYrz0iOI04kGABqQBC5m2ZWE=; b=piM0zHJ/LtunuO7crtBgjBUXwnzL1ys4D7DLilWsJntnoe5pdKgBCw9fr7f8e/XpaI 8FNcj9J54PlIOnbY5RHu7gNvktrwhuBPWBm9tnNwlBkotT64nTWRt1d5KKUsCfiwNN1c nP/nMfE+iTSGYJQMTolP9NH4LOE2Ijq3Pnr+qHj6IjNyZGOu8yvHX28kK/uxIdOcFxEw M6ojxIHukytbdjz1s4/Ym3gdj+v4jGyHmpptEgJe1cLsL1F/kTLw+QBa31CCFIMwJPgx SE8fnAcYApZriedGL+Xc9eWePRzLZgE5MceGZnAA10LONQgRJzTg/8n9jIZq2263x/5Q T+mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=2lq4K6S9wCit74ByAJsSYrz0iOI04kGABqQBC5m2ZWE=; b=m18C/UR1I6634DM1T2D5E2nGU7YA0EpvgvYF4kolDxhDi5wvY1iuldzBLu/9QvpSBf TOqnZe07+7AVlHd1WeN/x8jewyuYYIVu9+pw6Fde2UVnmcwYTNwmmtpIJR1T/wYm7vXv 5+f91ayFMyu8w7YauWrHA7HuMiQ4MQdi5JGYVmzf7+EZBcfKPQwWWuVuZtMb1fd/pTBP FjtAtJLve9uWH1zbqHTGLSjpLPEO4PcP/cqlZhqG86stJKRTrltoZxYzF+nOfP/3CDTH P32g1CnI2bKL+Bf+TtJRB6P1V1rFk82VsLgCCMExx2Vt+0Ft0zDxOCBtWN2S2iRKVbUx Ytyw== X-Gm-Message-State: AA6/9RlGEYzvC383622FW5HAPjmiqDvC25T8Is4fcqf1r3YA7BH3BU+/GZBDUO50iaCgHJmScMViPIyv32XKBg== X-Received: by 10.202.195.3 with SMTP id t3mr2301874oif.44.1475575637746; Tue, 04 Oct 2016 03:07:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.60.199 with HTTP; Tue, 4 Oct 2016 03:07:16 -0700 (PDT) In-Reply-To: References: Date: Tue, 4 Oct 2016 11:07:16 +0100 Message-ID: To: Yasuo Ohgaki Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Re: [RFC][DISCUSSION] Improve uniqid() uniqueness From: leight@gmail.com (Leigh) On 4 October 2016 at 02:39, Yasuo Ohgaki wrote: > Hi Leigh, > > On Mon, Oct 3, 2016 at 9:06 PM, Leigh 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 Since we want to preserve BC entropy = random_int(0, 99999999); uniqid = strpprintf(0, "%s%08x%05x.%08d", prefix, sec, usec, entropy);