def yw_proc(data, isEncrypt, key=None, head=None, validator=None):
out = bytearray()
length = len(data)
new_crc32 = struct.unpack("<I", data[-8:-4])[0]
seed = struct.unpack("<I", data[-4:])[0]
if not isEncrypt:
if binascii.crc32(data[:-8]) != new_crc32:
logging.error("Checksum does not match")
return None
c = YWCipher(seed, 0x1000)
out += c.encrypt(data[:-8])
out += data[-8:]
if isEncrypt:
new_crc32 = binascii.crc32(out[:-8])
struct.pack_into("<I", out, length - 8, new_crc32)
return bytes(out)
评论列表
文章目录