马上注册,免费下载更多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人回答
©DZ插件网所发布的一切资源仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。 本站内容为站长个人技术研究记录或网络,不提供用户交互功能,所有内容版权归原作者所有。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,得到更好的正版服务。 您在本站任何的赞助购买、下载、查阅、回复等行为等均表示接受并同意签订《DZ插件网免责声明协议》。 如有侵权请邮件与我们联系处理: discuzaddons@vip.qq.com 并出示相关证明以便删除。敬请谅解!
|
|