Rewrite the encryption mode of Baidu mp3 address with php

Source: Internet
Author: User
Using php to rewrite the Baidu mp3 address encryption method Baidu mp3 address is encrypted. you can see the specific encryption method for yourself. the decoding function is as follows: // copyrighthttp: // www.k686.com//authortuzwu58@gmail.comfunctiondecode (ur uses php to rewrite the encryption method of Baidu mp3 address

Baidu mp3 addresses are encrypted. you can see the specific encryption method. 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(10, 35, 55);//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 format of the input string is as follows:

Str = "o00w: // 333. osq. z0h0z. nv2.ju/q5/4p14phuzopN1hun/44zn977D7A9F8G-7A.twA ";
Var sertim = 1289225685;

?

The two variables must be included in the above function so that they can be resolved to a standard url address.

?

The following is the 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; // 1st times http://www.k686.com For ($ I = 0; $ I <= 9; $ I ++) {$ asc_arr1 [$ I] = $ I + 48; $ asc_arr2 [$ I + 48] = $ I;} // 2nd for ($ I = 10; $ I <= 35; $ I ++) {$ asc_arr1 [$ I] = $ I + 55; $ asc_arr2 [$ I + 55] = $ I ;}// 3rd times for ($ I = 36; $ I <= 61; $ I ++) {$ asc_arr1 [$ I] = $ I + 61; $ asc_arr2 [$ I + 61] = $ 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 = 'Oss 00w: // 333. osq. z0h0z. nv2.ju/q5/4p14phuzopN1hun/44zn977D7A9F8G-7A.twA '; $ sertim = 1289225685; echo decode ($ str, $ sertim );

?

I used php to rewrite the js function. the functions are 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.