TeaDecode: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server_client function}} | {{Server_client function}} | ||
{{New feature/item|3.0135|1.3.5|6056| | |||
{{New feature/item| | |||
This function decrypts given [https://en.wikipedia.org/wiki/Base64 base64] representation of encrypted data using the [https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm Tiny Encryption Algorithm]. | This function decrypts given [https://en.wikipedia.org/wiki/Base64 base64] representation of encrypted data using the [https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm Tiny Encryption Algorithm]. | ||
}} | }} | ||
{{Important Note|Use [[decodeString]] instead, because teaEncode inflates the file size by as high as ~77% (or by ~33% if the input isn't binary converted to base64 string).}} | |||
{{Important Note|teaDecode cannot handle binary data.}} | |||
==Syntax== | ==Syntax== | ||
Line 18: | Line 19: | ||
==Example== | ==Example== | ||
<section name="Example 1" class="client" show="true"> | <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 | This example creates a /teadecrypt command, which reverts the TEA on a given string with the specified key. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
[lua] | [lua] | ||
function | function decryptString( cmd, theString, theKey ) | ||
if theString | if ( theString ) and ( theKey ) then | ||
local decodedString = teaDecode( theString, theKey ) -- Decode the string with the key | |||
outputChatBox( "The decoded string is: " .. tostring( decodedString ) ) | |||
local decodedString = teaDecode(theString, | |||
outputChatBox("The | |||
else | else | ||
outputChatBox("Syntax: /" .. cmd .. " | outputChatBox( "Syntax: /" .. cmd .. " [string] [key]" ) | ||
end | end | ||
end | end | ||
addCommandHandler("teadecrypt", | addCommandHandler( "teadecrypt", decryptString ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> |
Latest revision as of 15:07, 16 September 2018
This function decrypts given base64 representation of encrypted data using the Tiny Encryption Algorithm.
Important Note: Use decodeString instead, because teaEncode inflates the file size by as high as ~77% (or by ~33% if the input isn't binary converted to base64 string). |
Important Note: teaDecode cannot handle binary data. |
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.
[lua] function decryptString( cmd, theString, theKey ) if ( theString ) and ( theKey ) then local decodedString = teaDecode( theString, theKey ) -- Decode the string with the key outputChatBox( "The decoded string is: " .. tostring( decodedString ) ) else outputChatBox( "Syntax: /" .. cmd .. " [string] [key]" ) end end addCommandHandler( "teadecrypt", decryptString )
See Also
- addDebugHook
- base64Decode
- base64Encode
- 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