let admin chose what password-hash-algorithm is to be used to crypt() passwords; fixes #852

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-04-14 18:41:21 +02:00
parent 271e4a660b
commit fb045c3fe1
10 changed files with 52 additions and 36 deletions

View File

@@ -18,7 +18,6 @@
/**
* Make crypted password from clear text password
* @param string Password to be crypted
* @param int Type of algorithm
* @return string encrypted password
*
* @author Michal Wojcik <m.wojcik@sonet3.pl>
@@ -30,29 +29,31 @@
* 4 - SHA-512 $6$
*/
function makeCryptPassword ($password, $type = 0)
{
switch($type)
{
case 0:
$cryptPassword = crypt($password);
break;
case 1:
$cryptPassword = crypt($password, '$1$' . generatePassword(). generatePassword());
break;
case 2:
$cryptPassword = crypt($password, '$2a$' . generatePassword(). generatePassword());
break;
case 3:
$cryptPassword = crypt($password, '$5$' . generatePassword(). generatePassword());
break;
case 4:
$cryptPassword = crypt($password, '$6$' . generatePassword(). generatePassword());
break;
default:
$cryptPassword = crypt($password);
break;
}
function makeCryptPassword ($password) {
return ($cryptPassword);
global $settings;
$type = isset($settings['system']['passwordcryptfunc']) ? (int)$settings['system']['passwordcryptfunc'] : 1;
switch ($type) {
case 0:
$cryptPassword = crypt($password);
break;
case 1:
$cryptPassword = crypt($password, '$1$' . generatePassword(). generatePassword());
break;
case 2:
$cryptPassword = crypt($password, '$2a$' . generatePassword(). generatePassword());
break;
case 3:
$cryptPassword = crypt($password, '$5$' . generatePassword(). generatePassword());
break;
case 4:
$cryptPassword = crypt($password, '$6$' . generatePassword(). generatePassword());
break;
default:
$cryptPassword = crypt($password);
break;
}
return $cryptPassword;
}