Joomla登入驗證,密碼加密方式

來源:互聯網
上載者:User

Joomla的密碼不是簡單的用MD5加密。

資料庫中的密碼是這樣儲存的:(使用者名稱和密碼都是admin)

ab9989726cacc2a382866650fe6c809d:64tjXqkuMhKth3GK9o6uBMilMTJhKJIe

中間是有冒號分開的,我們把第一部分記為part1    第二部分記為part2

即:

part1:part2

雖然我們不知道part2是怎麼加密來的(如果有哪位知道,還請指點一下!)

但是通過看joomla的原始碼,可以知道part1是這樣來的  part1=md5(username.part2);

我們可以寫自己的函數來驗證使用者名稱和密碼。

<?phpdefine( '_JEXEC', 1 );define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the rootdefine( 'DS', DIRECTORY_SEPARATOR);//引入Joomla架構,以便使用joomla的類庫require_once (JPATH_BASE.DS.'includes'.DS.'defines.php');require_once (JPATH_BASE.DS.'includes'.DS.'framework.php');$mainframe =&JFactory::getApplication('site');$mainframe->initialise();$user = &JFactory::getUser();if(!$user->get("username")){?>你還未登入!<?php}else{echo $user->get("password")."<br>";//echo JUserHelper::getCryptedPassword("admin");//echo md5("admin");//使用Joomla的類庫來查詢$db= JFactory::getDbo();$query= $db->getQuery(true);$query->select('id, password');$query->from('#__users');$query->where('username='.$db->Quote('admin'));$db->setQuery($query);$result = $db->loadObject();$parts= explode(':', $result->password);$testcrypt = md5("admin".$parts[1]);echo $testcrypt;?><?php }?>

ab9989726cacc2a382866650fe6c809d:64tjXqkuMhKth3GK9o6uBMilMTJhKJIeab9989726cacc2a382866650fe6c809d

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.