search
Homephp教程php手册WebQQ网页hash加密算法PHP版

由于最近QQ垃圾信息群发严重,官方选择将WebQQ部分功能实现细节方面做了点手脚,其中获取好友的POST值多了一个hash参数,这个hash是在js里加密完成的,以下是js源码:

function getHash(b, i) { 

for (var a = i + "password error", 

s = "",  

j = [];;) if (s.length

if (s += b, s.length == a.length) break 

} else { 

s = s.slice(0, a.length); 

break 

}    

for (var d = 0; d

a = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]; 

s = "";  

for (d = 0; d > 4 & 15], 

s += a[j[d] & 15]; 

return s; 

 

转成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(&#39;N&#39;, mb_convert_encoding($str, &#39;UCS-4BE&#39;, &#39;UTF-8&#39;));
    return $ord;
}
/* End of file commons.php */

   


教程链接:

随意转载~但请保留教程地址★

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment