本文整理汇总了PHP中SecurityUtil::checkSaltedHash方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityUtil::checkSaltedHash方法的具体用法?PHP SecurityUtil::checkSaltedHash怎么用?PHP SecurityUtil::checkSaltedHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecurityUtil
的用法示例。
在下文中一共展示了SecurityUtil::checkSaltedHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: passwordsMatch
/**
* Compare a password-like code to a hashed value, to determine if they match.
*
* Note that this is not limited only to use for user login passwords, but can be used where ever a human-readable
* password-like code is needed.
*
* @param string $unhashedPassword The password-like code entered by the user.
* @param string $hashedPassword The hashed password-like code that the entered password-like code is to be compared to.
*
* @return bool True if the $unhashedPassword matches the $hashedPassword with the given hashing method; false if they do not
* match, or if there was an error (such as an empty password or invalid code).
*/
public static function passwordsMatch($unhashedPassword, $hashedPassword)
{
$passwordsMatch = false;
if (!isset($unhashedPassword) || !is_string($unhashedPassword) || empty($unhashedPassword)) {
return LogUtil::registerArgsError();
}
if (!isset($hashedPassword) || !is_string($hashedPassword) || empty($hashedPassword) || strpos($hashedPassword, UsersConstant::SALT_DELIM) === false) {
return LogUtil::registerArgsError();
}
$passwordsMatch = SecurityUtil::checkSaltedHash($unhashedPassword, $hashedPassword, self::getPasswordHashMethods(true), UsersConstant::SALT_DELIM);
return $passwordsMatch;
}
示例2: passwordsMatch
/**
* Compare a password-like code to a hashed value, to determine if they match.
*
* Note that this is not limited only to use for user login passwords, but can be used where ever a human-readable
* password-like code is needed.
*
* @param string $unhashedPassword The password-like code entered by the user.
* @param string $hashedPassword The hashed password-like code that the entered password-like code is to be compared to.
*
* @return bool True if the $unhashedPassword matches the $hashedPassword with the given hashing method; false if they do not
* match, or if there was an error (such as an empty password or invalid code).
*/
public static function passwordsMatch($unhashedPassword, $hashedPassword)
{
$passwordsMatch = false;
if (!isset($unhashedPassword) || !is_string($unhashedPassword) || empty($unhashedPassword)) {
throw new \InvalidArgumentException(__('Invalid arguments array received'));
}
if (!isset($hashedPassword) || !is_string($hashedPassword) || empty($hashedPassword) || strpos($hashedPassword, UsersConstant::SALT_DELIM) === false) {
throw new \InvalidArgumentException(__('Invalid arguments array received'));
}
$passwordsMatch = SecurityUtil::checkSaltedHash($unhashedPassword, $hashedPassword, self::getPasswordHashMethods(true), UsersConstant::SALT_DELIM);
return $passwordsMatch;
}