Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88663 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72453 invoked from network); 4 Oct 2015 10:57:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2015 10:57:08 -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.212.170 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:35439] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2F/E6-31315-20601165 for ; Sun, 04 Oct 2015 06:57:07 -0400 Received: by wicge5 with SMTP id ge5so84336719wic.0 for ; Sun, 04 Oct 2015 03:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=PSVQ/FqxBa8ieUnjzIhN0mwQcbxdE9eyAokUsXR47Hc=; b=0XHhLAIEoZVgK/OW0wAyLlFYovH+woEv9cX5essHT4BKRoroU5DfmsbqSGsKE5Prar AL92hbD6CWpZnc0155WERkUHGvBU1xKmWJhotTVcqLskDh2dbuOlHlUFLcfaPefulhIg oH9v7s2sirpYCxcoWQ4LXBqyaCWesvO2mw88xWwCypaechUwh3Ngok6wJbd3rtFqjdOg waNmexHhDdrMAbpQPFUmzgBqv2swle8t83zecHFdTcqrFC0AvQCfgbd5TbIdoZUiOate vP+x+BuL90T3atGjXFYObCDF7uwXStj0YfdK2eFdCojSrcy7/BU6ctRKjZJSaNcnHe/g cMCg== X-Received: by 10.194.71.39 with SMTP id r7mr28253916wju.120.1443956224059; Sun, 04 Oct 2015 03:57:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 04 Oct 2015 10:56:54 +0000 Message-ID: To: Scott Arciszewski , PHP Internals Content-Type: multipart/alternative; boundary=047d7bd916a8ce6e4805214541a1 Subject: Re: [PHP-DEV] PHP 7.1 - should we add a random_str() function? From: leight@gmail.com (Leigh) --047d7bd916a8ce6e4805214541a1 Content-Type: text/plain; charset=UTF-8 On Wed, 30 Sep 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 Function prototype: > string random_str( int $length, string $charset) Would return a string or throw an Error|Exception (e.g. invalid input parameters, or the operating system's CSPRNG begins to melt). I can write up an RFC for this, with a patch targeting 7.1, if anyone is interested in it. Scott Arciszewski Chief Development Officer Paragon Initiative Enterprises -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php Hey Scott Just quickly for reference, there was some discussion on this before in Feb, roughly here: https://marc.info/?l=php-internals&m=142481367620609&w=2 Not sure how relevant, havent reread it. --047d7bd916a8ce6e4805214541a1--