WebQQ hash加密算法PHP版
生活随笔
收集整理的這篇文章主要介紹了
WebQQ hash加密算法PHP版
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
由于最近QQ垃圾信息群發嚴重,官方選擇將WebQQ部分功能實現細節方面做了點手腳。其中獲取好友的POST值多了一個hash參數。
這個hash是在js里加密完成的。
以下是js源碼
| <script type="text/javascript"> function getHash(b, i) {for (var a = i + "password error",s = "", j = [];;) if (s.length <= a.length) { if (s += b, s.length == a.length) break} else {s = s.slice(0, a.length);break} for (var d = 0; d < s.length; d++) j[d] = s.charCodeAt(d) ^ a.charCodeAt(d);a = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];s = ""; for (d = 0; d < j.length; d++) s += a[j[d] >> 4 & 15],s += a[j[d] & 15];return s; } </script> |
轉成PHP版本處理,源碼如下
| <?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 */ |
轉載于:https://www.cnblogs.com/Jerry-blog/p/5010251.html
總結
以上是生活随笔為你收集整理的WebQQ hash加密算法PHP版的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ScrollView 分割屏幕效果
- 下一篇: linux中send函数MSG_NOSI