迅雷链接的编码与解码

2018-03-08  本文已影响18人  52_St
# 编码(JS)
function ThunderEncode(t_url) {

    var thunderPrefix = "AA";

    var thunderPosix = "ZZ";

    var thunderTitle = "thunder://";

    var thunderUrl = thunderTitle + base64encode(utf16to8(thunderPrefix + t_url + thunderPosix));

    return thunderUrl;
}

# 翻译成(Python)
import base64

def ThunderEncode(t_url):

    thunderPrefix = 'AA'
    
    thunderPosix = 'ZZ'
    
    thunderTitle = 'thunder://'

    thunderUrl = thunderTitle + base64.b64decode((thunderPrefix + t_url + thunderPosix).encode('utf-8'))
    
    return thunderUrl
# 解码
import base64
from urllib.parse import unquote


def ThunderDecode(thunderUrl):

    t_url = unquote(base64.b64decode(thunderUrl[10:]).decode('utf-8')[2:-2])

    return t_url
上一篇下一篇

猜你喜欢

热点阅读