AbstractHasher.php
TLDR
This file contains the AbstractHasher
class, which provides common methods for hashing and verifying values.
Methods
info
This method takes a hashed value as input and returns information about the hash. It calls the password_get_info
function and returns its result as an array.
check
This method compares a plain value against a hashed value to check if they match. It takes the plain value, the hashed value, and an optional array of options as input. If the hashed value is null or empty, it returns false. Otherwise, it calls the password_verify
function with the plain and hashed values and returns the result as a boolean.
<?php
namespace Illuminate\Hashing;
abstract class AbstractHasher
{
/**
* Get information about the given hashed value.
*
* @param string $hashedValue
* @return array
*/
public function info($hashedValue)
{
return password_get_info($hashedValue);
}
/**
* Check the given plain value against a hash.
*
* @param string $value
* @param string|null $hashedValue
* @param array $options
* @return bool
*/
public function check($value, $hashedValue, array $options = [])
{
if (is_null($hashedValue) || strlen($hashedValue) === 0) {
return false;
}
return password_verify($value, $hashedValue);
}
}