ReferenceEncoding and crypto

lz4compress

Compresses a byte string with LZ4.

Syntax

lz4compress(data: string) -> string

Also available as

crypt.lz4compresslz4_compress

Parameters

ParameterTypeDescription
datastringUncompressed bytes.

Returns

TypeDescription
stringCompressed binary representation.

Description

The result is binary data and can contain zero bytes. Keep the original uncompressed size when exchanging data with another LZ4 implementation. Compression is not encryption and does not authenticate the input.

Example

local text = string.rep("sample", 100)
local packed = lz4compress(text)
print(#text, #packed)
assert(lz4decompress(packed, #text) == text)

These are Game executor contracts. Check build requirements and session lifetimes before using them.