Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88627 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66230 invoked from network); 1 Oct 2015 23:03:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Oct 2015 23:03:07 -0000 Authentication-Results: pb1.pair.com header.from=j.boggiano@seld.be; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=j.boggiano@seld.be; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain seld.be designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: j.boggiano@seld.be X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:37082] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/F6-26330-7ABBD065 for ; Thu, 01 Oct 2015 19:03:05 -0400 Received: by wicfx3 with SMTP id fx3so9389368wic.0 for ; Thu, 01 Oct 2015 16:03:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=w10xpgWdNjJbcVYf5eC/FQT7C+H5xoHps2uLm4mdVi8=; b=grg5aiR+o0mJdb8TEGrBUBSTBC8875pYTe4cN2S3VBg4a48aCf3JizV+q7Qii6Nrtm cz5N9QiTKJbUYb79pE6G2KyYqctePYnYwNhLNV92pXLPSfMKgFj56K37r2Nd8oRi/9pt BpKu2Vk6ra/xsR44kr5eSXYBWiSB/8H+LiqjukZwx4DPKPNRs+9IGJrFwh1uREz0PN1f T3RMpWB4dj15bIBtAyAGQFP1CS4UjxJ5JYY+zbQUbneaQoU4QzooePA/BaZPTsr1/wte IrHsNK16GDrU18rwZonZ2qtGr9ehOIFE7igsmT4bj+fGDkFpzNXSMt7ImEzh//SoT8Q4 FV1Q== X-Gm-Message-State: ALoCoQk3v16IP5873gbW/mnrJKSdX7oM4V5QQSr0ueqKk5ZN54dKYfr87qkpNskU2sw0xd+P/+zi X-Received: by 10.180.81.199 with SMTP id c7mr1042038wiy.87.1443740580408; Thu, 01 Oct 2015 16:03:00 -0700 (PDT) Received: from [192.168.0.24] ([197.86.205.41]) by smtp.googlemail.com with ESMTPSA id pk7sm8402938wjb.2.2015.10.01.16.02.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2015 16:02:58 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <560DBBAC.9080504@seld.be> Date: Fri, 2 Oct 2015 00:03:08 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.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] PHP 7.1 - should we add a random_str() function? From: j.boggiano@seld.be (Jordi Boggiano) On 30/09/2015 17:15, Scott Arciszewski wrote: > This is probably answerable by a quick yes/no and shouldn't need a ton > of bikeshedding, but if that happens anyway I apologize in advance. > > I think random_bytes() and random_int() are great; they provide a > much-needed building block in PHP 7.0. However, I do worry a bit that > the most common use for random_int() (generating a random string of a > fixed length with a given character set) will be reinvented over and > over again, and rarely consistently. > > I would propose a random_str() function that behaves similar to this > userland snippet: http://stackoverflow.com/a/32870871/2224584 Sounds great, and the amount of different answers on this stack overflow question highlights the problem very well IMO. Cheers -- Jordi Boggiano @seldaek - http://seld.be