def decrypt(keys, cipher_text):
"""
???????
:param keys: list(), ?? [11, 22, 33 ,44]
:param cipher_text: str(), ???? 16 ???, ?? "5b0dcfc68c8d58e9c5680e4c"
:return: str(), ??????, ?? "hello,world!"
"""
result_list = [int() for j in range(len(cipher_text) // 2)]
for i in range(0, len(cipher_text), 6):
temp = int(cipher_text[i:i + 6], 16)
for j in range(3):
temp &= (1 << 24) - 1
temp = (temp << 17) | (temp >> 7)
temp ^= keys[temp & 3] << 8
result_list[i // 2] = (temp & 0xff0000) >> 16
result_list[i // 2 + 1] = (temp & 0xff00) >> 8
result_list[i // 2 + 2] = (temp & 0xff)
# ?????, ??????, ???????????????
for j in range(3):
if chr(result_list[i // 2 + j]) not in string.printable:
return ""
return "".join([chr(each) for each in result_list])
评论列表
文章目录