base65536.py 文件源码

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

项目:GCTF-challenges 作者: PlatyPew 项目源码 文件源码
def decode(value):
    """Decodes bytes from a base65536 string."""
    stream = io.BytesIO()
    done = False
    for ch in value:
        code_point = ord(ch)
        b1 = code_point & ((1 << 8) - 1)
        try:
            b2 = B2[code_point - b1]
        except KeyError:
            raise ValueError('Invalid base65536 code '
                             'point: %d' % code_point)
        b = int2byte(b1) if b2 == -1 else int2byte(b1) + int2byte(b2)
        if len(b) == 1:
            if done:
                raise ValueError('base65536 sequence '
                                 'continued after final byte')
            done = True
        stream.write(b)
    return stream.getvalue()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号