decodeString | Multi Theft Auto: Wiki Skip to content

decodeString

Client-side
Server-side
Shared
Needs checking

This function was partially migrated from the old wiki. Please review manually:

  • Missing section: Options for each algorithm

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function decodes an encoded string using the specified algorithm. The counterpart of this function is encodeString.

Syntax

string decodeString ( string algorithm, string input, table options, function callback )
Required Arguments
  • algorithm: The algorithm to use.
  • input: The input to decode.
  • options: MISSING_PARAM_DESC
  • callback: providing a callback will run this function asynchronously, the arguments to the callback are the same as the returned values below.

Returns

  • string: value

Returns the decoded string if successful, false otherwise. If a callback was provided, the decoded string is argument to the callback.

Code Examples

shared

Adds a/decodecommand in which you can provide an algorithm, key and data to decode.

addCommandHandler("decode",
function(player, _, algorithm, key, ...)
if algorithm and key then
local text = table.concat({...}, " ")
if type(text) == "string" and text ~= "" then
local decoded = decodeString(algorithm, text, { key = key })
if decoded then
outputChatBox("The result of " .. algorithm .. " decoding is: " .. decoded, player)
else
outputChatBox("Failed to decode. Make sure that all arguments are valid.", player, 255, 0, 0)
end
else
outputChatBox("Please specify text in the command.", player, 255, 0, 0)
end
else
outputChatBox("Invalid algorithm and/or key.", player, 255, 0, 0)
end
end
)