laravel 中使用 Hash::make() 對用戶密碼進行加密
問題描述: 在調試中發現使用 Hash:make($password) 對用戶密碼進行加密;在驗證時發現對於相同的password 會出現不同的加密結果,那麼加密之後進行對比肯定是不相等的。
看了下實現方式: 使用 Hash::check($password,$userInfo->password)
這種方式來對密碼進行校驗,不能使用 Hash:make($password) == $userInfo->password
來進行判斷。
先關代碼如下:
<?php
namespace Illuminate\Support\Facades;
/**
* @method static array info(string $hashedValue)
* @method static bool check(string $value, string $hashedValue, array $options = [])
* @method static bool needsRehash(string $hashedValue, array $options = [])
* @method static string make(string $value, array $options = [])
*
* @see \Illuminate\Hashing\HashManager
*/
class Hash extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'hash';
}
}