teaEncode | Multi Theft Auto: Wiki Skip to content

teaEncode

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

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


This functions performs the Tiny Encryption Algorithm on the given string and returns the base64 representation of the encrypted string.

Important

Use encodeString 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).

Syntax

teaEncode ( )

Code Examples

server

This example creates a /teaencrypt command, which performs the TEA on a given string with the specified key, if any.

function encryptString( cmd, theString, theKey )
if ( theString ) then
if ( not theKey ) then
theKey = string.rep( string.char( math.random( string.byte( "a" ), string.byte( "Z" ) ) ), 10 ) -- Generate a random key of 10 characters if no key was passed in as an argument
end
local encodedString = teaEncode( theString, theKey ) -- Encode the string with the key
outputChatBox( "The encoded string is: " .. tostring( encodedString ) .. " (used key: " .. theKey .. ")" )
else
outputChatBox( "Syntax: /" .. cmd .. " [string] <[key]>" )
end
end
addCommandHandler( "teaencrypt", encryptString )