Cryptography

lz4compress

Compresses a string using LZ4 to reduce size before storage or transfer.

Syntax

lz4compress(data: string): string
Aliases crypt.lz4compresscrypt.lz4.compresslz4.compress

Arguments

NameTypeDescription
datastringInput byte string or text processed by the function.

Returns

NameTypeDescription
compressedstringCompressed byte string.

Description

Compresses a string using LZ4 to reduce size before storage or transfer.

Call it with 1 parameter(s): data. The argument table explains which values are required and which ones only refine the behavior.

It returns compressed (string). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Compress a string and restore it using its original size.

local source = string.rep("Real Docs ", 100)
local compressed = lz4compress(source)
local restored = lz4decompress(compressed, #source)

print(#source, #compressed, restored == source)