public function hash(#[\SensitiveParameter] string $plainPassword, string $salt = null): string
{ if ($this->
isPasswordTooLong($plainPassword)) { throw new InvalidPasswordException();
} if (!\
in_array($this->algorithm,
hash_algos(), true
)) { throw new LogicException(sprintf('The algorithm "%s" is not supported.',
$this->algorithm
));
} $salted =
$this->
mergePasswordAndSalt($plainPassword,
$salt);
$digest =
hash($this->algorithm,
$salted, true
);
// "stretch" hash
for ($i = 1;
$i <
$this->iterations; ++
$i) { $digest =
hash($this->algorithm,
$digest.
$salted, true
);
} return $this->encodeHashAsBase64 ?
base64_encode($digest) :
bin2hex($digest);
} public function verify(string
$hashedPassword, #[\SensitiveParameter] string $plainPassword, string $salt = null): bool