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 tuzwu58@gmail.com function decode (URL) {var 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 tuzwu58@gmail.com 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.
?