用php改寫百度mp3地址的加密模式

來源:互聯網
上載者:User
用php改寫百度mp3地址的加密方式

百度mp3地址是加密過的,具體加密方式大家自己看吧.解碼函數如下:

//copyright http://www.k686.com //author [email protected]                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;                }

?

傳入的字串格式形如:

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

?

兩個變數需要帶入到上面的函數,這樣才能解析為一個標準的url地址.

?

下面是php改寫後的:

 //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;//第1次 http://www.k686.com                        for ($i = 0; $i <= 9; $i++) {                            $asc_arr1[$i] = $i + 48;                            $asc_arr2[$i + 48] = $i;                        }//第2次                        for ($i = 10; $i <= 35; $i++) {                            $asc_arr1[$i] = $i + 55;                            $asc_arr2[$i + 55] = $i;                        }//第3次                        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 = 'o00w://333.osq.z0h0z.nv2.ju/q5/4p14phuzopN1hun/44zn977D7A9F8G-7A.twA';$sertim = 1289225685;echo decode($str,$sertim);

?

算是用php改寫了js函數,功能是一模一樣的.傳入的兩個參數都可以在百度mp3頁面找得到的.

?

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.