solve.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:qlcoder 作者: L1nwatch 项目源码 文件源码
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])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号