Fix when random_int is not available
This commit is contained in:
parent
415fbc19af
commit
2b3fbecd49
@ -514,8 +514,15 @@ function getRandomPassword($generic=false, $replaceambiguouschars=null)
|
|||||||
{
|
{
|
||||||
$numbers = "ABCDEF";
|
$numbers = "ABCDEF";
|
||||||
$max = strlen($numbers) - 1;
|
$max = strlen($numbers) - 1;
|
||||||
|
if (function_exists('random_int')) // Cryptographic random
|
||||||
|
{
|
||||||
$generated_password=str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password);
|
$generated_password=str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$generated_password=str_replace($replaceambiguouschars, $numbers{mt_rand(0, $max)}, $generated_password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $generated_password;
|
return $generated_password;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user