Skip to main content

compress_string

Compresses a string using GZIP and optionally injects a randomized filename into the GZIP header to modify the output's byte structure.

def compress_string(
s: str | bytes,
max_random_bytes: int | None = None
) - > bytes

Compresses a string using GZIP and optionally injects a randomized filename into the header to vary the output's binary representation.

Parameters

NameTypeDescription
s`strbytes`
max_random_bytes`intNone` = None

Returns

TypeDescription
bytesThe GZIP-compressed byte string, potentially containing a randomized filename field in the header.