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

Discuz! 官方交流社區(qū)

標(biāo)題: x3.5 登錄驗(yàn)證問題 [打印本頁]

作者: xujingad    時(shí)間: 2023-8-17 16:52
標(biāo)題: x3.5 登錄驗(yàn)證問題
我想自己寫個(gè)登錄,然后是密碼校驗(yàn)這步不太懂這些參數(shù)取自哪里:

在網(wǎng)上扒教程,定位到/uc_client/user.php,約365行的這幾個(gè)方法(最底部):
這里有幾個(gè)疑問,在pre_ucenter_members的salt字段為空字符串時(shí),應(yīng)該走的分支:password_verify($password, $hash);
隨后兩個(gè)參數(shù)$algo和$options我沒看懂,雖然我用返回的是true,但是這里沒有和數(shù)據(jù)庫的密碼作比對,也可以判斷嗎?
$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;
    }









歡迎光臨 Discuz! 官方交流社區(qū) (http://m.sdtechgong.com.cn/) Powered by Discuz! X5.0