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));
 | 
			
		||||
			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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.
 | 
			
		||||
*
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue