教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 WebQQ网页hash加密算法PHP版

WebQQ网页hash加密算法PHP版

发布时间:2016-10-26   编辑:jiaochengji.com
教程集为您提供WebQQ网页hash加密算法PHP版等资源,欢迎您收藏本站,我们将为您提供最新的WebQQ网页hash加密算法PHP版资源
我们在QQ网上找到的一个hash加密算法是js版本的,下面我们根据js版的hash加密算法改成php版的加密算法,希望方法对各位有帮。

由于最近QQ垃圾信息群发严重,官方选择将WebQQ部分功能实现细节方面做了点手脚。其中获取好友的POST值多了一个hash参数。

这个hash是在js里加密完成的。

以下是js源码

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy7134')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy7134>

<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版本处理,源码如下

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy6343')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy6343><?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 */

您可能感兴趣的文章:
WebQQ网页hash加密算法PHP版
【哈希密码】PHP比md5更安全的加密方式
php crypt函数加密和解密的实例分享
WebQQ最新登陆协议的例子
php hash算法实例分享
Go从入门到精通系列视频之go编程语言密码学哈希算法
golang使用bcrypt加密算法进行密码的加密与校验
php字符串哈希函数算法实现代码
Python常用模块之hashlib
python hash是什么

[关闭]
~ ~