lz4compress Synchronous
crypt.lz4.compresscrypt.lz4compresslz4.compress
Pack a byte string as an LZ4 block for fast storage or transfer. It works best when the input contains repeated material; short inputs can grow instead of shrinking.
Luau
lz4compress(data: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
data | string | Text or binary bytes to compress. |
Returns
stringAn LZ4 block as a binary string. Save or transmit it as bytes, or Base64-encode it for a text-only destination.
Usage notes
Keep the compression format with the saved data so the reader can choose lz4decompress. This call does not create a ZIP file.
Example
Luau
local original = string.rep("inventory=full;", 40)
local packed = lz4compress(original)
print(#original, #packed)
assert(lz4decompress(packed) == original)