WEBQQ page Hash Encryption algorithm PHP version _php tutorial

Source: Internet
Author: User
We found on the QQ online hash encryption algorithm is the JS version, the following we are based on the JS version of the hash encryption algorithm to PHP version of the encryption algorithm, I hope the method for you to help.

As a result of the recent mass of QQ spam, the official choice will webqq part of the function to achieve the details of some hands and feet. Which gets the post value of a friend more than a hash parameter.

This hash is encrypted in JS.

The following is the JS source code

The code is as follows Copy Code

Converted to PHP version processing, the source code is as follows

The code is as follows Copy Code
/**
* Post parameter hash algorithm when getting a friend
*
* Public
* @param string $QQ QQ number
* @param string $ptwebqq ptwebqq in cookies
* @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;
}

/**
* Analog JavaScript charCodeAt function
*
* 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.html www.bkjia.com true http://www.bkjia.com/PHPjc/632811.html techarticle we found on the QQ online hash encryption algorithm is the JS version, the following we are based on the JS version of the hash encryption algorithm to PHP version of the encryption algorithm, I hope the method for you to help. Because of the recent Q ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.