久久久久av_欧美日韩一区二区在线_国产精品三区四区_日韩中字在线

返回列表 發帖
查看: 654|回復: 0

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

10

主題

24

回帖

40

積分

初學乍練

貢獻
0 點
金幣
5 個
樓主
發表于 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人回答
回復

使用道具 舉報

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

本版積分規則

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

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

GMT+8, 2025-9-21 04:08 , Processed in 0.070612 second(s), 24 queries .

Powered by Discuz! W1.0 Licensed

Copyright © 2001-2025 Discuz! Team.

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