lz4compress Synchronous
crypt.lz4.compresscrypt.lz4compresslz4.compress
Compress a string’s bytes into an LZ4 block. Pass the returned string to lz4decompress when the original data is needed again. Use it to reduce repetitive data before storage or transfer. The output is binary; retain the format information so the reader knows which decompressor to use.
Luau
lz4compress(data: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
data | string | Uncompressed text or binary bytes. |
Returns
stringAn LZ4 block as a byte string. The result is not printable text, and small inputs may become larger after compression.
Example
Luau
local original = string.rep("saved data;", 20)
local compressed = lz4compress(original)
print(#original, #compressed)
assert(lz4decompress(compressed) == original)