2
0
forked from Wavyzz/dolibarr

Merge branch '14.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur
2021-07-05 18:47:24 +02:00
9 changed files with 87 additions and 76 deletions

View File

@@ -476,8 +476,8 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
}
$generated_password = str_shuffle($randomCode);
} else // Old platform, non cryptographic random
{
} else {
// Old platform, non cryptographic random
$max = strlen($lowercase) - 1;
for ($x = 0; $x < $nbofchar; $x++) {
$tmp = mt_rand(0, $max);

View File

@@ -99,7 +99,7 @@ class modGeneratePassStandard extends ModeleGenPassword
$password = "";
// define possible characters
$possible = "0123456789bcdfghjkmnpqrstvwxyz";
$possible = "0123456789qwertyuiopasdfghjklzxcvbnmASDFGHJKLZXCVBNMQWERTYUIOP";
// set up a counter
$i = 0;
@@ -107,10 +107,13 @@ class modGeneratePassStandard extends ModeleGenPassword
// add random characters to $password until $length is reached
while ($i < $this->length) {
// pick a random character from the possible ones
$char = substr($possible, mt_rand(0, dol_strlen($possible) - 1), 1);
if (function_exists('random_int')) { // Cryptographic random
$char = substr($possible, random_int(0, dol_strlen($possible) - 1), 1);
} else {
$char = substr($possible, mt_rand(0, dol_strlen($possible) - 1), 1);
}
// we don't want this character if it's already in the password
if (!strstr($password, $char)) {
if (substr_count($password, $char) <= 6) { // we don't want this character if it's already 5 times in the password
$password .= $char;
$i++;
}