Documentation Index
Fetch the complete documentation index at: https://mintlify.com/PrinceOfCookies/CookieOS/llms.txt
Use this file to discover all available pages before exploring further.
cosUtils ships a self-contained cryptography and data-utility layer built entirely in Lua for use inside CC:Tweaked. It provides LZW compression (compress/decompress), RC4 stream cipher encryption (used internally), MD5 integrity hashing (also internal), hex encoding helpers, a character-interleaving helper, and a high-level Package/UnPackage pipeline that chains all three primitives together.
cosUtils.compress(input, ignoreSize)
Compresses a string using an LZW-based algorithm. If the compressed output turns out to be the same size or larger than the input (andignoreSize is not true), the function returns the original string with a "u" prefix to signal that it is stored uncompressed. Successfully compressed data is returned with a "c" prefix. Both prefixes are understood by cosUtils.decompress().
The string to compress. Must be a
string; passing any other type returns nil and an error message.If
true, the compressed output is returned even if it is larger than the input (i.e. always returns the "c"-prefixed compressed form).compressedString (string) on success, or nil, errorMessage (string) on failure.
cosUtils.decompress(input)
ReversescosUtils.compress(). Reads the first byte to determine whether the data is compressed ("c") or stored raw ("u") and processes accordingly. Returns nil and an error message if the input is missing the control prefix or is otherwise malformed.
A string previously returned by
cosUtils.compress(). Must begin with "c" or "u".decompressedString (string) on success, or nil, errorMessage (string) on failure.
cosUtils.Package(KEY, data)
High-level encryption pipeline. Encryptsdata with the RC4 stream cipher using KEY, compresses the encrypted result with LZW, appends a 16-byte MD5 hash of KEY .. compressedData for integrity verification, and returns the finished payload.
Encryption key. For correct RC4 operation the key must be exactly 16 bytes. The function asserts this length requirement internally.
The plaintext string to encrypt and package.
string.
cosUtils.isPackaged(KEY, data)
Verifies whetherdata was packaged with KEY by checking the appended MD5 hash. First attempts a full-data check (last 16 bytes as hash), then iterates through possible split points to handle segmented data.
The key that was used to call
cosUtils.Package().The packaged data string to verify.
isValid (boolean), compressedData (string | nil). On success compressedData is the verified compressed payload (without the hash suffix) ready to pass to cosUtils.decompress().
cosUtils.UnPackage(KEY, data)
Reverses the fullPackage() pipeline. Processes data in 16-byte segments, calling cosUtils.isPackaged() on each segment to find valid chunks. For each valid segment, it decompresses the payload and accumulates the results. Returns the concatenated plaintext of all valid segments.
The key originally used with
cosUtils.Package().The packaged data string returned by
cosUtils.Package().decryptedString (string) on success, or nil, errorMessage (string) if no valid data was found.
cosUtils.interleave(data1, data2)
Interleaves two strings character by character:data1[1], data2[1], data1[2], data2[2], …. If the strings are different lengths, the remaining characters of the longer string are appended at the end.
First input string.
Second input string.
string.
cosUtils.fromhex(str)
Converts a hexadecimal string (pairs of hex digits) into a binary string by parsing each two-character group as a byte value.A hex string with an even number of characters, e.g.
"48656C6C6F".string.
cosUtils.tohex(str)
Converts a binary string into an uppercase hexadecimal string. Each byte is formatted as two uppercase hex digits.Any binary or ASCII string to encode.
string.