Normalizes a password parameter into a [ id, encryption, integrity ]
object

@param string|array  $password  String or object with [ id, secret ] or
[ id, encryption, integrity ]
@return array
512178
protected function normalizePassword($password)
    {
        $obj = [];

        if (is_array($password)) {
            $obj['id'] = $password['id'];
            $obj['encryption'] = (isset($password['secret']) && $password['secret'] !== null)
                ? $password['secret']
                : $password['encryption'];
            $obj['integrity'] = (isset($password['secret']) && $password['secret'] !== null)
                ? $password['secret']
                : $password['integrity'];
        } else { // password is a string
            $obj['encryption'] = $password;
            $obj['integrity'] = $password;
        }

        return $obj;
    }
1262235
public function ntPasswordHash($password = null)
    {
        //if (isset($password)) {
        if (!is_null($password)) {
            return pack('H*',hash('md4', $this->str2unicode($password)));
        } else {
            return pack('H*',hash('md4', $this->str2unicode($this->password)));
        }
    }
857796
public static function compute(array $data, ?string $password = null): string
	{
		unset($data['signature']);

		if ($password !== null) {
			$data['password'] = $password;
		}

		if (!array_key_exists('password', $data)) {
			throw new MissingParameterException('password');
		}

		if (
			$data['password'] === null
			|| $data['password'] === ''
		) {
			throw new MissingParameterException('password');
		}

		return Digester::process($data);
	}
1056295
public static function getHashedPasswordWithSalt($password) {
		
		// salt for bcrypt needs to be 22 base64 characters (only [./0-9A-Za-z])
		$salt = substr(str_replace('+', '.', base64_encode(sha1(microtime(true), true))), 0, 22);
		
		// 2a = bcrypt algorithm selector, 12 = the workload factor
		$hash = crypt($password, '$2a$12$' . $salt);
		
		return $hash;

	}
231189
public function hash($password) {
        $salt = \ww_getSalt($this->saltLength);
        $hash = \ww_HashEncode($password.$salt);

        return $salt.'$'.$hash;
    }
1103639
public function checkPassword($password)
    {
        $valid = static::$dispatcher->until(new CheckingPassword($this, $password));

        if ($valid !== null) {
            return $valid;
        }

        return static::$hasher->check($password, $this->password);
    }
301969
protected function setPassword($password) {
        if (!isset($password)) $password = '';
        else if (!is_string($password)) throw new IllegalTypeException('Illegal type of parameter $password: '.gettype($password));

        $this->password = $password;
        return $this;
    }
730655
protected function normalize(array $parameters)
    {
        foreach ($parameters as $parameter => $value) {
            if (null !== $this->knownParameters[$parameter]) {
                $parameters[$parameter] = sprintf($this->knownParameters[$parameter], $value);
            }
        }

        return $parameters;
    }
746117
public static function getSaltedPasswordHash($password)
    {
        return hash('sha512', \App\Registry::$config->salt . md5($password) . $password . 'sltd');
    }
1017472
public function validate(string $password): array
    {
        $errors = [];

        if (!$this->isLongEnough($password)) {
            $errors[] = $this->createValidationError('User password must be at least %length% characters long', [
                '%length%' => $this->constraints['minLength'],
            ]);
        }

        if (!$this->containsAtLeastOneLowerCaseCharacter($password)) {
            $errors[] = $this->createValidationError('User password must include at least one lower case letter');
        }

        if (!$this->containsAtLeastOneUpperCaseCharacter($password)) {
            $errors[] = $this->createValidationError('User password must include at least one upper case letter');
        }

        if (!$this->containsAtLeastOneNumericCharacter($password)) {
            $errors[] = $this->createValidationError('User password must include at least one number');
        }

        if (!$this->containsAtLeastOneNonAlphanumericCharacter($password)) {
            $errors[] = $this->createValidationError('User password must include at least one special character');
        }

        return $errors;
    }
1069050
public static function passwordHash(string $password) : string
    {
        //cant use it aas a object property cause php sucks and can call a function on a property with a array -_-
        $options = [
            //'salt' => mcrypt_create_iv(22, MCRYPT_DEV_URANDOM), // Never use a static salt or one that is not randomly generated.
            'cost' => 12, // the default cost is 10
        ];

        $hash = password_hash($password, PASSWORD_DEFAULT, $options);

        return $hash;
    }
110244
private function hashPassword(string $password): string
    {
        $algorithm = Registry::getConfig()->getConfigParam('passwordHashingAlgorithm') ?? 'PASSWORD_BCRYPT';
        $passwordServiceBridge = $this->getContainer()->get(PasswordServiceBridgeInterface::class);

        return $passwordServiceBridge->hash($password, $algorithm);
    }
304740
public static function getHMACMD5Hash($password, $data) {
    $dataString = implode('', $data);

    return self::getHMACMD5HashString($password, $dataString);
  }
221226
public function encode( $password, $salt = null )
	{
		return ( isset( $this->hasher ) ? $this->hasher->getHashedPassword( $password, $salt ) : $password );
	}
288161
public function passwordRehash($password)
    {
        if (password_needs_rehash(
            $password,
            $this->config[ 'password' ][ 'algorithm' ],
            $this->config[ 'password' ][ 'options' ]
        )) {
            return $this->passwordHash($password);
        }

        return $password;
    }
408443
protected function normalizeKey($key)
    {
        if (preg_match(static::$arrayKey, $key, $matches)) {
            $key = $matches[1];
            return $key;
        }
        return $key;
    }
1127956
public function checkPassword($password)
    {
        Deprecation::notice('5.0', 'Use Authenticator::checkPassword() instead');

        // With a valid user and password, check the password is correct
        $result = ValidationResult::create();
        $authenticators = Security::singleton()->getApplicableAuthenticators(Authenticator::CHECK_PASSWORD);
        foreach ($authenticators as $authenticator) {
            $authenticator->checkPassword($this, $password, $result);
            if (!$result->isValid()) {
                break;
            }
        }
        return $result;
    }