How to compress data in memory? The simplest way is to use the Native API Compression by trancexx. Here provides another way, using LZMA algorithm. LZMA is the default method of 7z format, provides a high compression ratio and very fast decompression.
In this UDF, embedded and external DLL are both supported. If "LZMA.DLL.AU3" (embedded binary) is not included in scripts, a external LZMA.DLL must exists. You can use external DLL if MemoryDll is not work for you.
Both LzmaEnc and LzmaDec only accept binary arguments. To compress string, StringToBinary and BinaryToString can help.
LzmaEnc can accept an extra argument, the comression level, from 1 to 9. For example: LzmaEnc($Binary, 9)
More settings are support by LzmaEncSetting, please see LZMA SDK.
This UDF is not for file compression. To compress files, 7-ZIP UDF is the better choice
Local $Source = Binary("LZMALZMALZMALZMALZMALZMALZMALZMALZMALZMA")
Local $Compressed = LzmaEnc($Source)
Local $Decompressed = LzmaDec($Compressed)