ReferenceEncoding and crypto

zstdcompress

Compresses a byte string with Zstandard.

Syntax

zstdcompress(data: string, level: number?) -> string

Also available as

crypt.zstdcompresszstd_compress

Parameters

ParameterTypeDescription
datastringUncompressed bytes.
levelnumber?Optional Zstandard compression level (defaults to 3).

Returns

TypeDescription
stringZstandard-compressed binary frame.

Description

The result is a standard Zstandard binary frame that may contain zero bytes. Passing an out-of-range or non-integer compression level raises an error. Compression is not encryption and does not authenticate the input.

Example

local text = string.rep("sample", 100)
local packed = zstdcompress(text)
assert(zstddecompress(packed) == text)

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