Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118762 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77357 invoked from network); 5 Oct 2022 21:44:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Oct 2022 21:44:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 780721804C4 for ; Wed, 5 Oct 2022 14:44:31 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 5 Oct 2022 14:44:31 -0700 (PDT) Received: by mail-wr1-f49.google.com with SMTP id bu30so7870559wrb.8 for ; Wed, 05 Oct 2022 14:44:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wcflabs.de; s=google; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=M3iV6AwnSwlLi9DJD6azzgjJuYBqayOAKO660K1JgcE=; b=iNuhLcy9WhR295sZ3jtoPAFCkmmJZB+AehBEK8b9ED45PtfFi2t8T2YXcOErTh9Jis Q9rHxt/8LY9GQSrqKWvzcJUmduUFuWqhfxtzIEaqhw8izhewJNExbAPPychwIE1cNXJp E1f27pHvZ+QkZaT7B3xJv3nBztE8MQNd0yiILa9N1RIYvS9kto07w22PvZPZMzjRedpL 5arBQK9/jdXY9nu89NjM3FZIPz7nUkEDlKXlzPGbHj8vfCWfk4eziTttxu4g/G0ep78i 6p0ACwWb/AwsGhygMvvYpFLlID4epOGeg0/RQjCDCRdcvxErdHnpEl7zE3jc/Z5S52RO TsIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=M3iV6AwnSwlLi9DJD6azzgjJuYBqayOAKO660K1JgcE=; b=OKLW9uAh/uDA0k/3DEjYTpfYUSEpewB/V0W5/7Qa82ZmZk7hMVRfIt6KbfNtrm9/vJ s90RUS1NcqQaYWchEEQsYW8Cn2tRn+3sFoGYOE4yB6P4DiK2pCRIbe7yDS56EMkdfryY lIWvqmra6fuqXmGOPiH+m9nl4tlSrfpv2sAPMZF6ivGRWO18S7MadjQvQ0KUfcqnYJ/K HO435qn2sssCyG2mMQWmAVeuVAs9fJvcIeeXq7tDIPN8A1xIrgBzxY2GFT7n4M3xx3iP jGcIG8awWfcGww04GQ0iVcYD56lM9HhgqKhb06lp4bgw131qUph0K4EwQcoO3+W/Kzj+ t6Nw== X-Gm-Message-State: ACrzQf3pPQtB4wjBXNqgGr1PKI9ApbiSqtOqOxDHEYKRPVfiSKvj9DSJ H31f/NgYPikx3UnekpNxqTE8uHw8Yn76hA== X-Google-Smtp-Source: AMsMyM5ZufBFP9+AQ2/4cZ540a5wKAlVtZQWJq9QwFHEMKqAupSd8LEJL+nb/l7pc/GI49rK19pCXw== X-Received: by 2002:a5d:6d07:0:b0:22a:3f21:3b56 with SMTP id e7-20020a5d6d07000000b0022a3f213b56mr954831wrq.679.1665006270040; Wed, 05 Oct 2022 14:44:30 -0700 (PDT) Received: from ?IPV6:2a02:908:d12:2d80:3049:228:2d04:8dae? ([2a02:908:d12:2d80:3049:228:2d04:8dae]) by smtp.gmail.com with ESMTPSA id j13-20020a5d452d000000b00228a6ce17b4sm15949272wra.37.2022.10.05.14.44.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Oct 2022 14:44:29 -0700 (PDT) Message-ID: Date: Wed, 5 Oct 2022 23:44:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Content-Language: de-DE To: internals@lists.php.net Reply-To: =?UTF-8?Q?Joshua_R=c3=bcsweg?= Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Pre RFC - Additions to the randomizer From: internals@lists.php.net ("Joshua Rüsweg via internals") Hi I would like to introduce a new method for the new Randomizer class [1]. I would like to have a function that generates a random string for me based on a given alphabet. This function is useful as a building block, as many use cases require generating random strings with a specified list of characters (e.g. random passwords, voucher codes, numeric strings larger than integers) and implementing this in userland requires multiple lines of code for what effectively is a very simple operation. Furthermore the obvious implementation based on ->getInt() is inefficient, as it requires at least one call to the engine per character, whereas a 64 Bit engine could generate randomness for 8 characters at once. I have opened a Pull-Request on PHP to demonstrate the implementation [2] but I am unsure about the method name and decided for `getBytesFromAlphabet()` but I am open for better suggestions. During code review Go Kudo requested that this goes through an RFC and Tim Düsterhus requested to handle multiple new methods in bulk. Tim implemented a new method, which returns a random float value [3], since that's non-trivial to do in userland and an equally useful building block like my introduced method. Since the class into which this function is built is final anyway, the methods can be built in with full backwards compatibility. I look forward to feedback from you! [1] https://wiki.php.net/rfc/random_extension_improvement [2] https://github.com/php/php-src/pull/9664 [3] https://github.com/php/php-src/pull/9679 PS: Since this is my first contribution, someone needs to give me karma to open an RFC. My account name is `josh`. Cheers Joshua Rüsweg