php - codeigniter中的Bcrypt散列
问题描述
我正在开发一些以前使用 md5 进行密码散列的 codeigniter webapp,我想更改为 Bcrypt。我已经成功地对密码进行了哈希处理,但我似乎无法理解为什么即使密码错误,登录代码也会返回 true。任何密码都将登录...我仍在学习 php,所以请多多关照。
这是我的登录功能
public function login()
{
$email= $this->input->post('email', TRUE);
$password= $this->input->post('password', TRUE);
$data['email']= $email;
$data['password']= password_verify($this->input->post('password', TRUE), PASSWORD_DEFAULT);
$sess_array=array();
$getdata=$this->Api_model->getSingleRow('admin',$data);
if($getdata)
{
if($getdata->status==1)
{
$this->session->unset_userdata($sess_array);
$sess_array = array(
'name' => $getdata->name,
'id' => $getdata->id,
);
$this->session->set_userdata( $sess_array);
$dataget['get_data'] =$getdata;
$dataget['see_data'] =$sess_array;
redirect('Admin/home');
}
else
{
$this->session->set_flashdata('block', ' Contact to admin.');
redirect('');
}
}
else
{
$this->session->set_flashdata('msg', 'Please enter valid Username or Password');
redirect('');
}
} ```
这是密码的注册码
$data['password']= password_hash($this->input->post('password', TRUE),PASSWORD_DEFAULT) ;
解决方案
推荐阅读
- exception - 如何在 Camel 的 errorHandler 中设置类型为 DeadLetterChannel 的记录器名称?
- matlab - 改变神经网络中 Sigmoid 激活函数的斜率 - MATLAB
- html - 不能下载文件
- php - “/user/home/appname/storage/logs”中没有现有目录并且它不可构建:权限被拒绝
- powershell - powershell 脚本中的异常没有意义
- android - 如何将自定义数据发送给未来的构建器?
- javascript - 当我可以直接调用函数时,为什么在javascript中使用回调函数
- reactjs - 如何在本地运行我的 react 应用程序的生产版本?
- pyspark - Pyspark 爆破sql函数
- javascript - 如何在 Javascript/CSS 中制作一个具有恒定大小的框?