栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Joomla 3.2.1密码加密

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Joomla 3.2.1密码加密

尝试这个,

以下代码创建了Joomla标准密码 (旧版本1.5、1.7等)

 jimport('joomla.user.helper'); $salt = JUserHelper::genRandomPassword(32); $crypt = JUserHelper::getCryptedPassword($password_choose, $salt); $password = $crypt.':'.$salt;

Joomla 3.2+ 引入了PHP的密码算法 bcrypt, 但它要求最低PHP 5.3+。 如果您打算使用
bcrypt,请
确保您的服务器PHP版本能够做到这一点,请在此处阅读更多内容。

其他版本的Joomla使用以下方法( Joomla 3.x

 jimport('joomla.user.helper'); $yourpass = JUserHelper::hashPassword($password_choose);

较旧的算法在最新版本中也能正常工作,唯一的区别是较旧的版本创建了65个字符的密码,而新版本创建了34个字符串。 总是与更新版本一起使用

另外,如果您使用的是外部脚本,则应包括如下所示的Joomla框架。这应该在您的外部php文件的顶部

define( '_JEXEC', 1 );define('JPATH_base', dirname(__FILE__) );//this is when we are in the rootdefine( 'DS', DIRECTORY_SEPARATOR );require_once ( JPATH_base .DS.'includes'.DS.'defines.php' );require_once ( JPATH_base .DS.'includes'.DS.'framework.php' );$mainframe =& JFactory::getApplication('site');$mainframe->initialise();

您还提到了必须检查用户凭据,然后无需检查密码格式,并且在框架加载后,所有内容都只使用以下代码。

   $credentials['username'] = $data['username']; //user entered name   $credentials['password'] = $data['password']; //users entered password   $app = JFactory::getApplication();   $error = $app->login($credentials, $options);   if (!JError::isError($error)) {    // login success    }  else{    //Failed attempt   }

希望能帮助到你..



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/406352.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号