From ecfb9879e4723b2e215b944dacfb21f6199728ed Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 10 Oct 2017 18:55:43 +0200 Subject: [PATCH] removed obsolete convertHex2bin() --- lam/lib/account.inc | 16 ++++++++-------- lam/lib/config.inc | 4 ++-- lam/lib/ldap.inc | 11 ----------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 07366711..4487030f 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -157,14 +157,14 @@ function pwd_hash($password, $enabled = true, $hashType = 'SSHA') { $hash = "{CRYPT}" . crypt($password, '$6$' . generateSalt(16)); break; case 'MD5': - $hash = "{MD5}" . base64_encode(convertHex2bin(md5($password))); + $hash = "{MD5}" . base64_encode(hex2bin(md5($password))); break; case 'SMD5': $salt = generateSalt(4); - $hash = "{SMD5}" . base64_encode(convertHex2bin(md5($password . $salt)) . $salt); + $hash = "{SMD5}" . base64_encode(hex2bin(md5($password . $salt)) . $salt); break; case 'SHA': - $hash = "{SHA}" . base64_encode(convertHex2bin(sha1($password))); + $hash = "{SHA}" . base64_encode(hex2bin(sha1($password))); break; case 'PLAIN': $hash = $password; @@ -175,7 +175,7 @@ function pwd_hash($password, $enabled = true, $hashType = 'SSHA') { case 'SSHA': default: // use SSHA if the setting is invalid $salt = generateSalt(4); - $hash = "{SSHA}" . base64_encode(convertHex2bin(sha1($password . $salt)) . $salt); + $hash = "{SSHA}" . base64_encode(hex2bin(sha1($password . $salt)) . $salt); break; } // enable/disable password @@ -334,20 +334,20 @@ function checkPasswordHash($type, $hash, $password) { case 'SSHA': $bin = base64_decode($hash); $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); break; case 'SHA': - return (strcmp($hash, base64_encode(convertHex2bin(sha1($password)))) == 0); + return (strcmp($hash, base64_encode(hex2bin(sha1($password)))) == 0); break; case 'SMD5': $bin = base64_decode($hash); $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); break; case 'MD5': - return (strcmp($hash, base64_encode(convertHex2bin(md5($password)))) == 0); + return (strcmp($hash, base64_encode(hex2bin(md5($password)))) == 0); break; case 'CRYPT': $parts = explode('$', $hash); diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 432fb52a..7448f7aa 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -1110,7 +1110,7 @@ class LAMConfig { * @return String hash value */ 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 */ 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); } /** diff --git a/lam/lib/ldap.inc b/lam/lib/ldap.inc index a73a8ab6..4901976d 100644 --- a/lam/lib/ldap.inc +++ b/lam/lib/ldap.inc @@ -31,17 +31,6 @@ $Id$ /** Access to configuration data */ 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. *