男的舔女的下面视频在线播放-少妇愉情理仑片高潮日本-久久久久久国产一区二区三区-麻豆精品一区二区综合-国产精品超碰在线观看-网红极品女神精品视频在线-国产亚洲综合777-高清性视频一区二区播放-中文字幕第一页亚洲天堂

返回列表 發(fā)帖
查看: 892|回復: 0

[求助] x3.5 登錄驗證問題

10

主題

24

回帖

0

粉絲

初學乍練

貢獻
0 點
金幣
5 個
樓主
發(fā)表于 2023-8-17 16:52:14 |湖北| 只看樓主 |倒序瀏覽 |閱讀模式
我想自己寫個登錄,然后是密碼校驗這步不太懂這些參數取自哪里:

在網上扒教程,定位到/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代碼

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

    function get_passwordoptions() {
        $options = $this->base->settings['passwordoptions'];
        if(empty($options)) {
            return array();
        } else {
            $result = json_decode($options, true);
            return is_array($result) ? $result : array();
        }
    }

    function generate_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;
    }

    function verify_password($password, $hash, $salt = '') {
        if(empty($salt)) {
            return password_verify($password, $hash);
        } else if(strlen($salt) == 6) {
            return hash_equals($hash, md5(md5($password).$salt));
        } else if(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);
        }
        return false;
    }




我知道答案 回答被采納將會獲得1 貢獻 已有0人回答
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

  • 關注公眾號
  • 有償服務微信
  • 有償服務QQ

手機版|小黑屋|Discuz! 官方交流社區(qū) ( 皖ICP備16010102號 |皖公網安備34010302002376號 )|網站地圖|star

GMT+8, 2026-4-18 14:48 , Processed in 0.047388 second(s), 12 queries , Redis On.

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

關燈 在本版發(fā)帖
有償服務QQ
有償服務微信
返回頂部
快速回復 返回頂部 返回列表