TeaDecode: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
No edit summary  | 
				No edit summary  | 
				||
| Line 17: | Line 17: | ||
==Example==  | ==Example==  | ||
<section name="Example 1" class="client" show="true">  | |||
This example creates a /teadecrypt command, which reverts the TEA on a given string with the specified key, if any.  | |||
<syntaxhighlight lang="lua">  | <syntaxhighlight lang="lua">  | ||
[lua]  | |||
function decrypt(cmd, theString, key)  | |||
    if theString then  | |||
        if not key then  | |||
            key = string.rep(string.char(math.random(string.byte("a"), string.byte("Z"))), 10) -- Generate a random key of 10 characters  | |||
        end  | |||
        local decodedString = teaDecode(theString, key) -- Encode the string with the key  | |||
        outputChatBox("The encoded string is: " .. encodedString .. " (used key: " .. key .. ")")  | |||
    else  | |||
        outputChatBox("Syntax: /" .. cmd .. " (string) [key].")  | |||
    end  | |||
end  | |||
addCommandHandler("teadecrypt", decrypt)  | |||
[/lua]  | |||
</syntaxhighlight>  | </syntaxhighlight>  | ||
</section>  | |||
==See Also==  | ==See Also==  | ||
{{Utility functions}}  | {{Utility functions}}  | ||
Revision as of 15:16, 4 August 2014
| Script Example Missing Function TeaDecode needs a script example, help out by writing one. | |
Before submitting check out Editing Guidelines Script Examples.  | 
Syntax
string teaDecode ( string data, string key )
Required Arguments
- data: The block of data you want to decrypt
 - key: The key that should be used for decryption (Only first 16 characters are used)
 
Returns
Returns string containing the decrypted data if the decryption process was successfully completed, false otherwise.
Example
Click to collapse [-]
Example 1This example creates a /teadecrypt command, which reverts the TEA on a given string with the specified key, if any.
[lua]
function decrypt(cmd, theString, key)
    if theString then
        if not key then
            key = string.rep(string.char(math.random(string.byte("a"), string.byte("Z"))), 10) -- Generate a random key of 10 characters
        end
        local decodedString = teaDecode(theString, key) -- Encode the string with the key
        outputChatBox("The encoded string is: " .. encodedString .. " (used key: " .. key .. ")")
    else
        outputChatBox("Syntax: /" .. cmd .. " (string) [key].")
    end
end
addCommandHandler("teadecrypt", decrypt)
[/lua]
See Also
- addDebugHook
 - debugSleep
 - decodeString
 - encodeString
 - fromJSON
 - generateKeyPair
 - getColorFromString
 - getDevelopmentMode
 - getDistanceBetweenPoints2D
 - getDistanceBetweenPoints3D
 - getEasingValue
 - getNetworkStats
 - getNetworkUsageData
 - getPerformanceStats
 - getRealTime
 - getTickCount
 - getTimerDetails
 - getTimers
 - getFPSLimit
 - getUserdataType
 - getVersion
 - gettok
 - isTransferBoxVisible
 - setTransferBoxVisible
 - hash
 - inspect
 - interpolateBetween
 - iprint
 - isOOPEnabled
 - isTimer
 - killTimer
 - md5
 - passwordHash
 - passwordVerify
 - pregFind
 - pregMatch
 - pregReplace
 - removeDebugHook
 - resetTimer
 - setDevelopmentMode
 - setFPSLimit
 - setTimer
 - ref
 - deref
 - sha256
 - split
 - teaDecode
 - teaEncode
 - toJSON
 - tocolor
 - getProcessMemoryStats
 - utfChar
 - utfCode
 - utfLen
 - utfSeek
 - utfSub
 
- bitAnd
 - bitNot
 - bitOr
 - bitXor
 - bitTest
 - bitLRotate
 - bitRRotate
 - bitLShift
 - bitRShift
 - bitArShift
 - bitExtract
 - bitReplace