string|bool decodeString(string algorithm, string data [, table options = nil, function callback = nil])
Parameters
| Name | Type | Description |
|---|---|---|
| algorithm | string | "tea", "aes128", "rsa", "base64", "base32" or "zlib". |
| data | string | The text to decode. |
| options | table | A table of options: key, iv (for aes128, what encodeString returned), variant or, for zlib, format (without it, zlib or gzip is detected).default nil |
| callback | function | If given, the work runs in the background and the function gets the result (or false) when it is done.default nil |
Returns
The original text. With callback, true right away. false if the options are invalid or the operation failed.
Algorithms
options is required for "tea", "aes128" and "rsa".
| Algorithm | Options |
|---|---|
"tea" |
Key in key; only its first 16 bytes count. |
"aes128" |
AES-128 in CTR mode; key (16 bytes) and iv (the 16-byte IV returned by encodeString). |
"rsa" |
key holds the private key to decode (matching the public key used to encode). |
"base64" |
Optional variant = "URL" for the URL-safe alphabet. |
"base32" |
Optional variant = "HEX" for the hexadecimal alphabet. |
"zlib" |
Optional format (without it, zlib or gzip is detected automatically). |
Example
encodeString("zlib", fileGetContents("map.json"), { compression = 6 }, function(packed)
if packed then
print("compressed to " .. #packed .. " bytes")
end
end)