laravel Hash :: make继续给出不同的结果 [英] laravel Hash::make keep giving a different results

查看:505
本文介绍了laravel Hash :: make继续给出不同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在laravel 4中使用身份验证 我改变了桌子和莫贝尔的名字

I want to use the authentication in laravel 4 I changed the table's and mobel's name

当用户注册时,我拥有密码并保存,哈希为:

when the user register, I has the password and save it, the hash is :

$password = Hash::make(Input::get('password'));

,然后当用户登录时,我想先对他/她进行身份验证.我这样做是这样的:

and then when the user login I want ot authenticate him/her first. I do that like this:

if (Auth::attempt(array('username' => Input::get('usernaem'), 'password' => Hash::make(Input::get('password')))))
{
    return Redirect::intended('dashboard');
}

那永远不会成功.我尝试调试代码,看来Hask::make函数总是给出不同的结果.

and that never success. I tried to debug the code and it seems that the Hask::make function always give a different result.

我是否使用了良好的身份验证方法?该哈希函数的解决方案是什么?

Am I using a good authentication methods? what is the solution for that hash function ?

非常感谢

推荐答案

首先,尝试时不要使用Hash,它应该像这样:

At first, don't use Hash when attempting, it should be like this:

Auth::attempt(array('username' => Input::get('username'), 'password' => Input::get('password')));

由于您通过使用Hash::make()进行散列将密码手动存储在数据库中,然后将其粘贴到数据库中.因此可能是一个问题.将密码重新输入数据库,然后将其实用地插入,然后重试.

Since you stored the password in your database manually by making a hash using Hash::make() and then pasted it in the database. So it could be a problem. Re-enter the password into the database and insert it pragmatically, then try again.

此外,您可以使用Hash::check('password', $hashedPassword)检查密码.在Laravel网站上详细了解安全.使用迁移来填充伪造数据,不要手动将任何数据放入数据库中.

Also, you may check the password using Hash::check('password', $hashedPassword). Read more about security on Laravel website. Use migration to populate fake data, don't manually put any data into database.

这篇关于laravel Hash :: make继续给出不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆