【问题标题】:Change input password from varchar to md5 in Code Igniter在 Codeigniter 中将输入密码从 varchar 更改为 md5
【发布时间】:2018-06-03 14:44:03
【问题描述】:

你能帮帮我吗?我想将密码类型从 varchar 更改为 md5

代码:

$data = array(
              'email' => $this->input->post('email') ,
              'password' => $this->input->post('password')
                      );

【问题讨论】:

  • 当仅使用 MD5 或更好的散列函数来保存密码验证器是不够的,并且仅添加盐对提高安全性无济于事。而是使用随机盐在 HMAC 上迭代大约 100 毫秒,然后将盐与哈希一起保存。最好使用PBKDF2Rfc2898DeriveBytesArgon2password_hashBcrypt 等函数或类似函数。关键是让攻击者花费大量时间通过蛮力查找密码。

标签: codeigniter


【解决方案1】:

使用密码散列代替 md5。 php内置函数。

password_hash(string,PASSWORD_BCRYPT);

进行验证。

使用密码验证方法。

passord_verify($password,$hashed_password);

你可以这样做

$data = array(
              'email' => $this->input->post('email') ,
              'password' => password_hash($this->input->post('password'),PASSWORD_BCRYPT)
                      );

确保数据库列具有适当的字符长度。如果它的字符串类型,那么它没有问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-23
    • 2010-11-09
    • 2012-01-22
    • 2012-01-07
    • 1970-01-01
    相关资源
    最近更新 更多