·设为首页收藏本站📧邮箱修改🎁免费下载专区📒收藏夹👽聊天室
返回列表 发布新帖

x3.5 登录验证问题

161 0
发表于 2023-8-17 18:09:16 | 查看全部 阅读模式

马上注册,免费下载更多dz插件网资源。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我想自己写个登录,然后是密码校验这步不太懂这些参数取自哪里:

在网上扒教程,定位到/uc_client/user.php,约365行的这几个方法(最底部):
这里有几个疑问,在pre_ucenter_members的salt字段为空字符串时,应该走的分支:password_verify($password, $hash);
随后两个参数$algo和$options我没看懂,虽然我用返回的是true,但是这里没有和数据库的密码作比对,也可以判断吗?
$password = '123456'
constant('PASSWORD_BCRYPT') = '2y'


    $hash = password_hash($password, constant('PASSWORD_BCRYPT'), array());
    $pass = password_verify($password, $hash);
    var_dump($pass);




user.php代码

    functionget_passwordalgo() {
        $algo = $this->base->settings['passwordalgo'];
        if(empty($algo)) {
            returnconstant('PASSWORD_BCRYPT');
        } else {
            returnconstant($algo) === null ? constant('PASSWORD_BCRYPT') : constant($algo);
        }
    }

    functionget_passwordoptions() {
        $options = $this->base->settings['passwordoptions'];
        if(empty($options)) {
            returnarray();
        } else {
            $result = json_decode($options, true);
            returnis_array($result) ? $result : array();
        }
    }

    functiongenerate_password($password) {
        $algo = $this->get_passwordalgo();
        $options = $this->get_passwordoptions();
        $hash = password_hash($password, $algo, $options);
        return ($hash === false || $hash === null || !password_verify($password, $hash)) ? password_hash($password, PASSWORD_BCRYPT) : $hash;
    }

    functionverify_password($password, $hash, $salt = '') {
        if(empty($salt)) {
            returnpassword_verify($password, $hash);
        } elseif(strlen($salt) == 6) {
            returnhash_equals($hash, md5(md5($password).$salt));
        } elseif(strlen($salt) > 6 && strlen($salt) < 20 && file_exists(UC_ROOT ."lib/uc_password_$salt.class.php")) {
            $classname = "uc_password_$salt";
            include(UC_ROOT ."lib/uc_password_$salt.class.php");
            return$classname::verify_password($password, $hash);
        }
        returnfalse;
    }




我知道答案 回答被采纳将会获得1 贡献 已有0人回答
我要说一句 收起回复

回复

 懒得打字嘛,点击右侧快捷回复【查看最新发布】   【应用商城享更多资源】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

图文热点
关闭

站长推荐上一条 /1 下一条

投诉/建议联系

discuzaddons@vip.qq.com

未经授权禁止转载,复制和建立镜像,
如有违反,按照公告处理!!!
  • 联系QQ客服
  • 添加微信客服

联系DZ插件网微信客服|最近更新|Archiver|手机版|小黑屋|DZ插件网! ( 鄂ICP备20010621号-1 )|网站地图 知道创宇云防御

您的IP:18.117.123.149,GMT+8, 2025-2-22 18:59 , Processed in 0.234516 second(s), 70 queries , Gzip On, Redis On.

Powered by Discuz! X5.0 Licensed

© 2001-2025 Discuz! Team.

关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表