Rewrite the encryption mode of Baidu MP3 address with PHP

Source: Internet
Author: User
Using PHP to rewrite the encryption method of Baidu MP3 address

Baidu MP3 Address is encrypted, the specific encryption method everyone see it. The decoding function is as follows:

Copyright http://www.k686.com//author [email protected] function decode (URL) {VA                    R len = url.length;                    var decurl = "";                    var asc_arr1 = [], asc_arr2 = [];                   var key = Sertim% 26; Key = key?                    Key:1;                            function init (head, bottom, middle) {for (var i = head; I <= bottom; i++) {                            Asc_arr1[i] = i + middle;                        Asc_arr2[i + middle] = i;                    }} init (0, 9, 48);                    Init (//http://www.k686.com), Init (36, 61, 61);        for (var i = 0; i < len; i++) {var word = Url.charat (i);                            if (/[a-za-z0-9]/.test (word)) {var pos = asc_arr2[url.charcodeat (i)]-key;                             if (POS < 0)   pos + = 62;                        Word = String.fromCharCode (Asc_arr1[pos]);                    } Decurl + = Word;                } return Decurl; }

?

The string format passed in is as follows:

str = "O00w://333.osq.z0h0z.nv2.ju/q5/4p14phuzopn1hun/44zn977d7a9f8g-7a.twa";
var sertim = 1289225685;

?

Two variables need to be brought into the function above to resolve to a standard URL address.

?

Here is the following PHP rewrite:

 Copyright http://www.k686.com//author [email protected] function decode ($url, $sertim) {                    $len = strlen ($url);                    $decurl = "";                    $ASC _arr1 = Array (), $asc _arr2 = Array ();                   $key = $sertim% 26; $key = $key? $key: 1;//1th time http://www.k686.com for ($i = 0; $i <= 9; $i + +) {$ASC                            _arr1[$i] = $i + 48;                        $ASC _arr2[$i +] = $i;                            }//2nd time for ($i = ten; $i <=, $i + +) {$asc _arr1[$i] = $i + 55;                        $ASC _arr2[$i +] = $i;                            }//for the 3rd time for ($i = $i <=, $i + +) {$asc _arr1[$i] = $i + 61;                        $ASC _arr2[$i +) = $i;  }//end http://www.k686.com for ($i = 0; $i < $len; $i + +) {                      $word = substr ($url, $i, 1);                            if (Preg_match ("/[a-za-z0-9]/", $word)) {$pos = $asc _arr2[ord (substr ($url, $i, 1))]-$key;                            if ($pos < 0) {$pos + = 62;}                        $word = Chr ($asc _arr1[$pos]);                    } $decurl. = $word;                } return $decurl; } $str = ' O00w://333.osq.z0h0z.nv2.ju/q5/4p14phuzopn1hun/44zn977d7a9f8g-7a.twa '; $sertim = 1289225685;echo decode ($ STR, $SERTIM);

?

is the use of PHP rewrite the JS function, the function is exactly the same. The two parameters passed in can be found on the Baidu mp3 page.

?

  • 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.