Req #66728 [Com]: gmp_random is obsolete, switch to gmp_urandomm

From: Date: Thu, 24 Sep 2015 20:51:52 +0000
Subject: Req #66728 [Com]: gmp_random is obsolete, switch to gmp_urandomm
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196220@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66728&edit=1 ID: 66728 Comment by: rainer dot jung at kippdata dot de Reported by: asphp at dsgml dot com Summary: gmp_random is obsolete, switch to gmp_urandomm Status: Open Type: Feature/Change Request Package: GNU MP related PHP Version: Irrelevant Block user comment: N Private report: N New Comment: IMHO this issue can be closed: starting with PHP 5.6 there is gmp_random_range() which uses mpz_urandomm() and the old gmp_random() uses mpz_urandomb(). Both should be fine. Previous Comments: ------------------------------------------------------------------------ [2014-02-17 20:52:46] asphp at dsgml dot com Description: ------------ According to the docs mpz_random (i.e. gmp_random) is obsolete. It's also pretty useless since it returns digits in an undefined range. Instead switch to mpz_urandomm which lets you specify the max directly. PHP could either expose it as is and let people subtract to get the min, or PHP could make it easier and let people specify a min and max. PHP could require that people manually initialize the random state, or just go ahead and do it for them with gmp_randinit_mt. Also once this is a done a PHP warning should be emitted for use of gmp_random. See: https://gmplib.org/manual/Integer-Random-Numbers.html ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66728&edit=1

« previous php.bugs (#196220) next »