import base64
def gg(a, c):
f = h = 0
b = list(range(256))
result = ''
while h < 256:
f = (f + b[h] + ord(a[h % len(a)])) % 256
b[h], b[f] = b[f], b[h]
h += 1
q = f = h = 0
while q < len(c):
h = (h + 1) % 256
f = (f + b[h]) % 256
b[h], b[f] = b[f], b[h]
if isinstance(c[q], int):
result += chr(c[q] ^ b[(b[h] + b[f]) % 256])
else:
result += chr(ord(c[q]) ^ b[(b[h] + b[f]) % 256])
q += 1
return result
if __name__ == '__main__':
q = "MQXVSggWJLjT1vjI/eJxW9ai70Jv1w/CXBs="
a = base64.b64decode(bytes(q, 'ascii'))
code = gg('becaf9be', a)
print(code)
PHP怎么实现
就是一个 base64_decode() 函数调用。