Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68651 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30340 invoked from network); 28 Aug 2013 20:59:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Aug 2013 20:59:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@marc-bennewitz.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@marc-bennewitz.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain marc-bennewitz.de from 80.237.132.171 cause and error) X-PHP-List-Original-Sender: php@marc-bennewitz.de X-Host-Fingerprint: 80.237.132.171 wp164.webpack.hosteurope.de Received: from [80.237.132.171] ([80.237.132.171:51174] helo=wp164.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/66-33204-AB46E125 for ; Wed, 28 Aug 2013 16:59:38 -0400 Received: from dslb-088-072-006-167.pools.arcor-ip.net ([88.72.6.167] helo=[192.168.178.27]); authenticated by wp164.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) id 1VEmpz-00050s-NA; Wed, 28 Aug 2013 22:59:35 +0200 Message-ID: <521E64B6.30703@marc-bennewitz.de> Date: Wed, 28 Aug 2013 22:59:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 MIME-Version: 1.0 To: PHP Internals Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-bounce-key: webpack.hosteurope.de;php@marc-bennewitz.de;1377723578;cb26b53f; Subject: More powerful (and backward compatible) API of random number generator functions From: php@marc-bennewitz.de (Marc Bennewitz) Idea for an RFC for a more powerful (and backward compatible) API of random number generator functions. The following psaudocode is self explained (hopfully) const RAND_ALGO_LIBC const RAND_ALGO_MERSENNE_TWISTER const RAND_ALGO_OPENSSL const RAND_ALGO_GMP ... // changed functions (added optional $algo argument) void srand($seed = null, $algo = rand_algo_default()) int rand($min = 0, $max = getrandmax(), $algo = rand_algo_default()) mixed array_rand(array $input, $num_req = 1, $algo = rand_algo_default()) bool shuffle(array &$array, $algo = rand_algo_default()) string str_shuffle(string $str, $algo = rand_algo_default()) // new functions // set/get the default algo int rand_algo_default($algo = null) // get a list of available algos array rand_algo_list() // generate random $length bytes string str_rand($length = 1, $algo = rand_algo_default()) // deprecate functions mt_srand() mt_rand() mt_getrandmax() openssl_random_pseudo_bytes() gmp_random() What do you think?