diff options
author | Andrew Dolgov <[email protected]> | 2019-03-05 20:16:50 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2019-03-05 20:16:50 +0300 |
commit | 16a9bdc38708c0e3b81eae3a79216214d493b57e (patch) | |
tree | 779067f1e4fec80fa687bf0cf107937bfc0ac5e3 /install/index.php | |
parent | ef6d2b8a4efe2a0114e6c7c02d6522b358646c8c (diff) |
make_password: generate longer passwords by default, use better random function if available
Diffstat (limited to 'install/index.php')
-rwxr-xr-x | install/index.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/install/index.php b/install/index.php index accabe3d3..815422712 100755 --- a/install/index.php +++ b/install/index.php @@ -55,21 +55,28 @@ // } - function make_password($length = 8) { - + function make_password($length = 12) { $password = ""; $possible = "0123456789abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ*%+^"; - $i = 0; + $i = 0; while ($i < $length) { - $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); + + try { + $idx = function_exists("random_int") ? random_int(0, strlen($possible) - 1) : mt_rand(0, strlen($possible) - 1); + } catch (Exception $e) { + $idx = mt_rand(0, strlen($possible) - 1); + } + + $char = substr($possible, $idx, 1); if (!strstr($password, $char)) { $password .= $char; $i++; } } + return $password; } |