removed obsolete convertHex2bin()
This commit is contained in:
parent
b227a55a2b
commit
ecfb9879e4
|
@ -157,14 +157,14 @@ function pwd_hash($password, $enabled = true, $hashType = 'SSHA') {
|
||||||
$hash = "{CRYPT}" . crypt($password, '$6$' . generateSalt(16));
|
$hash = "{CRYPT}" . crypt($password, '$6$' . generateSalt(16));
|
||||||
break;
|
break;
|
||||||
case 'MD5':
|
case 'MD5':
|
||||||
$hash = "{MD5}" . base64_encode(convertHex2bin(md5($password)));
|
$hash = "{MD5}" . base64_encode(hex2bin(md5($password)));
|
||||||
break;
|
break;
|
||||||
case 'SMD5':
|
case 'SMD5':
|
||||||
$salt = generateSalt(4);
|
$salt = generateSalt(4);
|
||||||
$hash = "{SMD5}" . base64_encode(convertHex2bin(md5($password . $salt)) . $salt);
|
$hash = "{SMD5}" . base64_encode(hex2bin(md5($password . $salt)) . $salt);
|
||||||
break;
|
break;
|
||||||
case 'SHA':
|
case 'SHA':
|
||||||
$hash = "{SHA}" . base64_encode(convertHex2bin(sha1($password)));
|
$hash = "{SHA}" . base64_encode(hex2bin(sha1($password)));
|
||||||
break;
|
break;
|
||||||
case 'PLAIN':
|
case 'PLAIN':
|
||||||
$hash = $password;
|
$hash = $password;
|
||||||
|
@ -175,7 +175,7 @@ function pwd_hash($password, $enabled = true, $hashType = 'SSHA') {
|
||||||
case 'SSHA':
|
case 'SSHA':
|
||||||
default: // use SSHA if the setting is invalid
|
default: // use SSHA if the setting is invalid
|
||||||
$salt = generateSalt(4);
|
$salt = generateSalt(4);
|
||||||
$hash = "{SSHA}" . base64_encode(convertHex2bin(sha1($password . $salt)) . $salt);
|
$hash = "{SSHA}" . base64_encode(hex2bin(sha1($password . $salt)) . $salt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// enable/disable password
|
// enable/disable password
|
||||||
|
@ -334,20 +334,20 @@ function checkPasswordHash($type, $hash, $password) {
|
||||||
case 'SSHA':
|
case 'SSHA':
|
||||||
$bin = base64_decode($hash);
|
$bin = base64_decode($hash);
|
||||||
$salt = substr($bin, 20);
|
$salt = substr($bin, 20);
|
||||||
$pwdHash = base64_encode(convertHex2bin(sha1($password . $salt)) . $salt);
|
$pwdHash = base64_encode(hex2bin(sha1($password . $salt)) . $salt);
|
||||||
return (strcmp($hash, $pwdHash) == 0);
|
return (strcmp($hash, $pwdHash) == 0);
|
||||||
break;
|
break;
|
||||||
case 'SHA':
|
case 'SHA':
|
||||||
return (strcmp($hash, base64_encode(convertHex2bin(sha1($password)))) == 0);
|
return (strcmp($hash, base64_encode(hex2bin(sha1($password)))) == 0);
|
||||||
break;
|
break;
|
||||||
case 'SMD5':
|
case 'SMD5':
|
||||||
$bin = base64_decode($hash);
|
$bin = base64_decode($hash);
|
||||||
$salt = substr($bin, 16);
|
$salt = substr($bin, 16);
|
||||||
$pwdHash = base64_encode(convertHex2bin(md5($password . $salt)) . $salt);
|
$pwdHash = base64_encode(hex2bin(md5($password . $salt)) . $salt);
|
||||||
return (strcmp($hash, $pwdHash) == 0);
|
return (strcmp($hash, $pwdHash) == 0);
|
||||||
break;
|
break;
|
||||||
case 'MD5':
|
case 'MD5':
|
||||||
return (strcmp($hash, base64_encode(convertHex2bin(md5($password)))) == 0);
|
return (strcmp($hash, base64_encode(hex2bin(md5($password)))) == 0);
|
||||||
break;
|
break;
|
||||||
case 'CRYPT':
|
case 'CRYPT':
|
||||||
$parts = explode('$', $hash);
|
$parts = explode('$', $hash);
|
||||||
|
|
|
@ -1110,7 +1110,7 @@ class LAMConfig {
|
||||||
* @return String hash value
|
* @return String hash value
|
||||||
*/
|
*/
|
||||||
private function hashPassword($password, $salt) {
|
private function hashPassword($password, $salt) {
|
||||||
return "{SSHA}" . base64_encode(convertHex2bin(sha1($password . $salt))) . " " . base64_encode($salt);
|
return "{SSHA}" . base64_encode(hex2bin(sha1($password . $salt))) . " " . base64_encode($salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2445,7 +2445,7 @@ class LAMCfgMain {
|
||||||
* @return String hash value
|
* @return String hash value
|
||||||
*/
|
*/
|
||||||
private function hashPassword($password, $salt) {
|
private function hashPassword($password, $salt) {
|
||||||
return "{SSHA}" . base64_encode(convertHex2bin(sha1($password . $salt))) . " " . base64_encode($salt);
|
return "{SSHA}" . base64_encode(hex2bin(sha1($password . $salt))) . " " . base64_encode($salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,17 +31,6 @@ $Id$
|
||||||
/** Access to configuration data */
|
/** Access to configuration data */
|
||||||
include_once("config.inc");
|
include_once("config.inc");
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a HEX string to a binary value
|
|
||||||
*
|
|
||||||
* @param string $value HEX string
|
|
||||||
* @return binary result binary
|
|
||||||
*/
|
|
||||||
function convertHex2bin($value) {
|
|
||||||
return pack("H*", $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ldap manages connection to LDAP and includes several helper functions.
|
* Ldap manages connection to LDAP and includes several helper functions.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue