解密虾米data-mp3(凯撒阵列加密)

加密数据:
7h%1.3F3E59%.t2.n3315E35mtFxe83%16Epp%it27227563%2a%1%F56383Fm2%5%28_7AfiF2E5%966

图解凯撒列阵加密

7表示有7行,从左到右竖着看。连起来是http%3A%2F%2Ff1.xiami.net%2F33821%2F337%5E31%2F%5E5%252%5E1768993653_6%5E6876.mp3经过urldecode后变成 http://f1.xiami.net/33821/337^31/^5%2^1768993653_6^6876.mp3把^变成0,就是 http://f1.xiami.net/33821/337031/05%201768993653_606876.mp3

逐步解析
调试图解

源码

from urllib import parse


# 解密经过加密的dataMp3内容
def dataMp3(s):
    num_loc = s.find('h')
    rows = int(s[0:num_loc])
    strlen = len(s) - num_loc
    cols = int(strlen / rows)
    right_rows = strlen % rows
    new_s = list(s[num_loc:])
    output = ''
    for i in range(len(new_s)):
        x = i % rows
        y = i / rows
        # p = 0
        if x <= right_rows:
            p = x * (cols + 1) + y
        else:
            p = right_rows * (cols + 1) + (x - right_rows) * cols + y
        output += new_s[int(p)]
    return parse.unquote(output).replace('^', '0')

GitHub上的应用

你可能感兴趣的:(解密虾米data-mp3(凯撒阵列加密))