upload_ted.py 文件源码

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

项目:ted-editor 作者: tarnheld 项目源码 文件源码
def deflate(data, compresslevel=9):
    # Compress
    compress = zlib.compressobj(compresslevel, zlib.DEFLATED, -zlib.MAX_WBITS, zlib.DEF_MEM_LEVEL, 0)
    deflated = compress.compress(data)
    deflated += compress.flush()
    # Add PDs compression magic and negated file length (8 bytes)
    length = int(-len(deflated))
    magic = bytearray(b'\xc5\xee\xf7\xff\x00\x00\x00\x00')
    magic[4] = byte(length, 0)
    magic[5] = byte(length >> 8, 0)
    magic[6] = byte(length >> 0x10, 0)
    magic[7] = byte(length >> 0x18, 0)
    deflatedwithheader = bytes(magic) + deflated
    finaldata = xor(deflatedwithheader)
    return finaldata

# Decrypts the GT6TED, removes the magic and negated file length and
# decompresses the data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号