WebQQ網頁hash密碼編譯演算法PHP版_PHP教程

來源:互聯網
上載者:User
我們在QQ網上找到的一個hash密碼編譯演算法是js版本的,下面我們根據js版的hash密碼編譯演算法改成php版的密碼編譯演算法,希望方法對各位有幫。

由於最近QQ垃圾資訊群發嚴重,官方選擇將WebQQ部分功能實現細節方面做了點手腳。其中擷取好友的POST值多了一個hash參數。

這個hash是在js裡加密完成的。

以下是js源碼

代碼如下 複製代碼

轉成PHP版本處理,源碼如下

代碼如下 複製代碼
/**
* 擷取好友時的POST參數Hash演算法
*
* public
* @param string $qq qq號
* @param string $ptwebqq cookies中的ptwebqq
* @return string
*/
function get_hash($qq, $ptwebqq)
{
for ($a = $ptwebqq . "password error", $s = "", $j = array();;)
{
if (strlen($s) <= strlen($a))
{
$s .= $qq;
if ($s == strlen($a)) break;
}
else
{
$s = substr($s, 0, strlen($a));
break;
}
}

for ($d = 0; $d < strlen($s); $d++)
{
$j[$d] = uniord(substr($s,$d)) ^ uniord(substr($a,$d));
}

$a = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
$s = "";
for ($d = 0; $d < count($j); $d++)
{
$s .= $a[$j[$d] >> 4 & 15];
$s .= $a[$j[$d] & 15];
}

return $s;
}

/**
* 類比 JavaScript charCodeAt函數
*
* protected
* @param string $str
* @return int
*/
function uniord($str)
{
list(, $ord) = unpack('N', mb_convert_encoding($str, 'UCS-4BE', 'UTF-8'));

return

$ord;
}

/* End of file commons.php */

http://www.bkjia.com/PHPjc/632811.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632811.htmlTechArticle我們在QQ網上找到的一個hash密碼編譯演算法是js版本的,下面我們根據js版的hash密碼編譯演算法改成php版的密碼編譯演算法,希望方法對各位有幫。 由於最近Q...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.