本文整理匯總了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;
}