Php Hash::make(';password';)在每次调用时返回不同的结果
所以,这个标题基本上描述了我的问题。 我的Hash:make()已经疯了。 我已经用哈希密码创建了一个users表,但我无法让Laravel接受我的凭据,我认为问题出在Hash::make中 因此,请测试此代码:Php Hash::make(';password';)在每次调用时返回不同的结果,php,hash,laravel-4,mcrypt,eloquent,Php,Hash,Laravel 4,Mcrypt,Eloquent,所以,这个标题基本上描述了我的问题。 我的Hash:make()已经疯了。 我已经用哈希密码创建了一个users表,但我无法让Laravel接受我的凭据,我认为问题出在Hash::make中 因此,请测试此代码: Route::get('/', function() { return Hash::make('1234'); }); 每次我点击路线“/”时,它都会给我一个不同的哈希值 对每个人来说都是这样吗? 有什么建议吗?我迷路了 在火箭发射后,我试过 if(!Hash::c
Route::get('/', function()
{
return Hash::make('1234');
});
每次我点击路线“/”时,它都会给我一个不同的哈希值
对每个人来说都是这样吗?
有什么建议吗?我迷路了
在火箭发射后,我试过
if(!Hash::check('1234', User::find(1)->password))
return 'not';
$credentials = array(
'email' => 'email@example.com',
'password' => '1234',
//'remember' => $remember
);
if(Auth::attempt($credentials))
{
return View::make('hello');
}
return "Invalid Credentials";
但它不断返回“无效凭证”。
我已经仔细检查了auth.php,它的设置正确。
还有什么我可以试试的吗?这就是它应该做的。它应该每次创建一个不同的密码,因为它正在创建一个新的随机密码 要检查用户密码,请使用
check
方法
if(Hash::check('1234', $password)){
}
或者您可以使用Auth::trunt
$user = array(
'email' => $email,
'password' => $password
);
if (Auth::attempt($user)){
}
文档:听起来你好像看到了盐。你不需要自己运行
Auth::check
,因为Auth::trunt
会为你这样做。您是否以任何方式更改了默认的User
模型?我没有。mysql表是users,控制器是User,字段是email和password。这是出厂设置。