- Documentation
- Shared functions
- teaEncode
Function
teaEncode
Encrypts text with the TEA cipher and returns base64, compatible with the standard TEA used by existing scripts, so previously encrypted text can be read here. Only the first 16 bytes of the key count. TEA is not a strong cipher; use encodeString with aes128 for serious data.
Syntax
string teaEncode(string text, string key)Arguments
textstring- The text.
keystring- The key.
Returns
Encrypted text (base64); empty text gives an empty result.
Example
local secret = teaEncode("kod 1234", "klucz")
outputServerLog(teaDecode(secret, "klucz")) -- kod 1234
Notes
The cipher pads the text with zero bytes to a multiple of 4 and teaDecode returns them with the text. Text whose length is a multiple of 4 comes back unchanged.
Before the 2026-10-09 version Trilogy Hub encrypted TEA in a non-standard way. The new version cannot read text encrypted by the old one.
See also
teaDecodeDecrypts text fromteaEncode(also from other servers) with the same key. A wrong key gives no error, just different bytes.encodeStringEncrypts, encodes or compresses text. Works on the server and on the client. Algorithms:tea(raw TEA bytes, no base64),aes128(the key must be exactly 16 characters; it also returns a randomivneeded to decrypt),rsa(a public key fromgenerateKeyPair),base64(varianturl),base32(the Crypto++ alphabet, varianthex= RFC 4648 base32hex),zlib(formatgzip,zliborraw, level 0-9, strategy). Withbase64,base32andzlibthe options table can be left out. With a callback the result goes to it in the next frame and the function returnstrue.