Encoding
Base64 encode/decode and LZ4 compress/decompress. Works on its own or through crypt.
Base64 and LZ4, available on their own and through crypt. Base64 when binary needs to be text, LZ4 when it needs to be small.
Both ways
local raw = readfile("assets/blob.bin")
-- Small.
local packed = lz4compress(raw)
local restored = lz4decompress(packed, #raw) -- needs the original size
-- Text-safe.
local encoded = base64encode(raw)
local decoded = base64decode(encoded)Save the original length
lz4decompress needs the uncompressed size, so store it with the data. A little JSON object with two keys is usually easiest.