【发布时间】:2021-01-20 01:28:31
【问题描述】:
我正在尝试解密存储在 MySQL Workbench 数据库中的密码。我使用了 codeigniter 的 Encrypt() 函数。它进入数据库就好了。但是当我尝试运行这段代码时,我得到了错误:消息:strlen()期望参数1是字符串,给定文件名的对象:库/加密.php 我想将通过表单输入的密码与数据库中的解密密码进行比较,看看它们是否匹配。我不知道如何纠正这个问题,我知道这可能是一个非常菜鸟的问题,但我很困惑。感谢您的帮助!
{
$this->db->select("custPassword");
$this->db->from('customer');
$this->db->where('custEmail', $customerEmail);
$passencrypted = $this->db->get();
$passplain = $this->encryption->decrypt($passencrypted);
$this->db->select("custNumber");
$this->db->from('customer');
$this->db->where('custEmail', $customerEmail);
$this->db->where('custPassword', $passplain);
$query = $this->db->get();
$count = $query->num_rows();
if($count == 1)
{
return true;
}
else
{
return false;```
【问题讨论】:
-
通常密码没有加密而是散列。因此,您无需解密密码以将其与未加密的输入进行比较,而是对输入进行哈希处理以与数据库中的哈希密码进行比较。见here
标签: php codeigniter encryption