mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 04:29:28 +01:00
use cryptographically secure random_int available in PHP 7+ when generating default passwords
This commit is contained in:
parent
c8605a0e7d
commit
ba8b1c403e
@ -292,10 +292,13 @@ class Auth
|
||||
$random_char = array_merge($random_char, str_split(str_replace('\\', '', self::SPECIALCHARS)), $random_char);
|
||||
}
|
||||
|
||||
// use cryptographically secure random_int available in PHP 7+
|
||||
$func = function_exists('random_int') ? 'random_int' : 'mt_rand';
|
||||
|
||||
$s = '';
|
||||
for ($i=0; $i < $size; $i++)
|
||||
{
|
||||
$s .= $random_char[mt_rand(0, count($random_char)-1)];
|
||||
$s .= $random_char[$func(0, count($random_char)-1)];
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
@ -550,10 +550,13 @@ function randomstring($len=16)
|
||||
'>','|','[',']','}', // dont add /\,'"{ as we have problems dealing with them
|
||||
);
|
||||
|
||||
// use cryptographically secure random_int available in PHP 7+
|
||||
$func = function_exists('random_int') ? 'random_int' : 'mt_rand';
|
||||
|
||||
$str = '';
|
||||
for($i=0; $i < $len; $i++)
|
||||
{
|
||||
$str .= $usedchars[mt_rand(0,count($usedchars)-1)];
|
||||
$str .= $usedchars[$func(0,count($usedchars)-1)];
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user