Compress Then Encrypt
Two decorator stacks around the same sink. The outermost wrapper transforms the payload first.
class Gzip:
def __init__(self, inner): self.inner = inner
def write(self, data: bytes) -> None:
self.inner.write(gzip.compress(data))
class Encrypt:
def __init__(self, inner, key): self.inner, self.key = inner, key
def write(self, data: bytes) -> None:
self.inner.write(aes_ctr(self.key, data)) # stream mode, no padding
stack_a = Gzip(Encrypt(File("out.bin"), KEY))
stack_b = Encrypt(Gzip(File("out.bin")), KEY)
The payload is 4 MB of newline-delimited JSON access logs. What comes out?
Sign in to answer questions and track your progress
Sign In