ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. teaEncode

Function

teaEncode

Server and clientMiscellaneousIdentical to MTA:SA

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