OpenCart客户密码加密

 小艾辰 发布于 2022-12-31 14:17

在我的iOS应用程序中,我试图允许用户使用他们当前在OpenCart系统中的用户信息登录到商店.如果我理解正确,则使用MD5加密密码.当我从应用程序加密密码时,它与数据库中存储的密码不匹配.有关为什么会这样的任何建议?关于如何解决它的任何建议?这是我第一次做过这类事情.

1 个回答
  • 根据OpenCart的用户模型,密码加密比MD5更复杂:

    public function addUser($data) {
        $this->db->query("INSERT INTO `" . DB_PREFIX . "user` SET username = '" . $this->db->escape($data['username']) . "', salt = '" . $this->db->escape($salt = substr(md5(uniqid(rand(), true)), 0, 9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', user_group_id = '" . (int)$data['user_group_id'] . "', status = '" . (int)$data['status'] . "', date_added = NOW()");
    }
    

    所以首先你生成这样的盐:

    $salt = substr(md5(uniqid(rand(), true)), 0, 9);
    

    然后你加密密码:

    $password = sha1($salt . sha1($salt . sha1($data['password'])));
    

    2022-12-31 14:20 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有