I am using GMP to create random generator.
here is the code
namespace Mdanter\Ecc\Random;
class GmpRandomNumberGenerator implements RandomNumberGeneratorInterface
{
/**
* @param bool $noWarn
*/
public function __construct($noWarn = false)
{
if ($noWarn !== true) {
trigger_error('Using non-secure random number generator.', E_USER_WARNING);
}
}
/**
* {@inheritDoc}
* @see \Mdanter\Ecc\RandomNumberGeneratorInterface::generate()
*/
public function generate($max)
{
$random = gmp_strval(gmp_random());
$small_rand = rand();
while (gmp_cmp($random, $max) > 0) {
$random = gmp_div($random, $small_rand, GMP_ROUND_ZERO);
}
return gmp_strval($random);
}
}
It's work fine in PHP 5 without any issue and error show. But when I try it in PHP 7 it show an error which is like this.
Warning: Using non-secure random number generator. in C:\xampp\htdocs\te.st\libs\vendor\mdanter\ecc\src\Random\GmpRandomNumberGenerator.php on line 13
Is there anyone can help me fix the error?
Aucun commentaire:
Enregistrer un commentaire