虽然目前爱奇艺的盐值是固定的,不过它也是通过函数算出来的。
算法函数需要慢慢看js跳来跳去分析。
这里是整理后的salt生成算法:
def bm(d,c):
return (((d & 65535) * (c & 65535)) + (((((d >> 16) & 65535) * (c & 65535) + (d & 65535) * ((c >> 16) & 65535)) << 16) >> 0) | 0)
def numtochar(ct, cq):
cn = (426025673 + (5 * ((27 * cq | 0) - (0 - (62 * ct | 0)) - (0 - (0 | bm(0 - (0 - (84 * cq | 0) - 21) | 0, 1910606658 + (28 * ct | 0) + 97 - 1910606658 | 0))) | 0) | 0) + 615 - 426025673 | 0) % 32 | 0
if cn < 10:
cn += 32
else:
cn += 72
cn += 16
return chr(cn)
chr_list = list()
cq = 0
for i in range(8):
for ct in range(4):
chr_list.append(numtochar(ct, cq))
if (ct + 1) % 4 == 0:
cq += 1
print("".join(chr_list))
简化之后后的代码:
def numtochar(ct, cq):
cn = (11 * cq + 18 * ct + 16 * cq * ct + 16) % 32
if cn < 10:
return chr(cn + 48)
else:
return chr(cn + 88)
chr_list = list()
for cq in range(8):
for ct in range(4):
chr_list.append(numtochar(ct, cq))
print("".join(chr_list))