From 9e91826dea53f16218fa41d0806309d365a28667 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Apr 2019 14:12:58 +0200 Subject: [PATCH] Can set length of random password --- htdocs/core/lib/security.lib.php | 2 +- htdocs/core/lib/security2.lib.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 8392b857061..0dbbb7f0829 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -109,7 +109,7 @@ function dol_decode($chain, $key = '1') * @param string $chain String to hash * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return string Hash of string - * @getRandomPassword + * @see getRandomPassword() */ function dol_hash($chain, $type = '0') { diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index f98985d0f74..596cdfb8e7e 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -448,14 +448,13 @@ function encodedecode_dbpassconf($level = 0) * @return string New value for password * @see dol_hash() */ -function getRandomPassword($generic = false, $replaceambiguouschars = null) +function getRandomPassword($generic = false, $replaceambiguouschars = null, $length = 32) { global $db,$conf,$langs,$user; $generated_password=''; if ($generic) { - $length = 32; $lowercase = "qwertyuiopasdfghjklzxcvbnm"; $uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP"; $numbers = "1234567890";