show only hash algorithms that are available on the system

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2015-02-15 07:51:58 +01:00
parent 37ca78913c
commit 1581e08594
2 changed files with 47 additions and 1 deletions

View File

@@ -45,7 +45,7 @@ return array(
'type' => 'option',
'default' => 0,
'option_mode' => 'one',
'option_options' => array(0 => $lng['serversettings']['systemdefault'], 1 => 'MD5', 2 => 'BLOWFISH', 3 => 'SHA-256', 4 => 'SHA-512'),
'option_options_method' => 'getAvailablePasswordHashes',
'save_method' => 'storeSettingField',
),
'system_allow_error_report_admin' => array(

View File

@@ -0,0 +1,46 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2015 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2014-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
* @since 0.9.33.1
*/
/**
* return an array of available hashes for the crypt() function
*
* @return array
*/
function getAvailablePasswordHashes()
{
global $lng;
// get available pwd-hases
$available_pwdhashes = array(
0 => $lng['serversettings']['systemdefault']
);
if (defined('CRYPT_MD5') && CRYPT_MD5 == 1) {
$available_pwdhashes[1] = 'MD5';
}
if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) {
$available_pwdhashes[2] = 'BLOWFISH';
}
if (defined('CRYPT_SHA256') && CRYPT_SHA256 == 1) {
$available_pwdhashes[3] = 'SHA-256';
}
if (defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) {
$available_pwdhashes[4] = 'SHA-512';
}
return $available_pwdhashes;
}