Aegis documentation
Everything you need to protect Lua & Luau code for Roblox and FiveM - and how tokens work.
Overview
Aegis transforms readable Lua/Luau source into protected code. You can use it on Roblox (Luau) and FiveM (Lua 5.4). Each encrypted file costs 1 token (the exact cost is configurable by the admin).
Keeps your output as valid Lua. Fastest, most compatible.
Compiles to a custom bytecode VM. Strongest protection.
Getting started
Create an account
Sign up or sign in from the navbar.
Add tokens
Buy a plan or redeem a key in the dashboard.
Encrypt
Paste your Lua, choose your macros, hit Encrypt.
Ship it
Download the protected file and deploy anywhere.
Protection layers
Each layer is an independent toggle in the dashboard.
String encryption
Every string literal is XOR-encrypted with a unique key and decoded by a memoizing helper at runtime. Plaintext never appears in the output, and repeated reads stay fast thanks to caching.
Number obfuscation
Integer constants become exact arithmetic expressions; floats become exact integer division. Hardcoded numbers disappear from the source.
Control-flow flattening
Statement lists become a shuffled state machine (while true / if state == N ...). The original order of your logic is destroyed.
Variable renaming
Scope-aware renaming scrambles locals, labels and (optionally) globals. Source identifiers are reserved first so generated names never collide.
Custom bytecode VM
VM onlyCompiles your program into a custom register-based instruction set and ships a self-contained Lua interpreter. String constants are encrypted in the constant pool.
Aegis macros (AEG_*)
Aegis ships its own macro family (modeled on Luraph's LPH_* macros). Macros are marker functions: Aegis never renames them and always protects their string/number arguments. You can call them freely - the runtime stubs below make them safe no-ops during local development.
-- Paste at the top of your source (or include aegis.lua):
local function AEG_OBFUSCATED() return nil end
local function AEG_ENCSTR(s) return s end
local function AEG_ENCNUM(n) return n end
local function AEG_ENCBUF(buf) return buf end
local function AEG_OPAQUE(x) return x end
local function AEG_CRASH() error("unreachable", 2) end
local function AEG_STACKALLOC(n) return n or 0 end
local function AEG_PRECHECK(c, m) if not c then error(m or "precheck", 2) end return true end
local function AEG_REWRITE() return nil end
local function AEG_LINE(n) return n end
local function AEG_NO_VIRTUALIZE(fn) return fn end
local function AEG_NO_OBFUSCATE(x) return x endAEG_OBFUSCATED()
AEG_OBFUSCATED()Marks a scope or function for full protection. A compatibility marker - with Aegis everything is already protected by default.
AEG_ENCSTR("text")
local k = AEG_ENCSTR("secret")Explicitly marks a string literal for encryption.
AEG_ENCNUM(n)
local x = AEG_ENCNUM(1337)Explicitly marks a number for obfuscation.
AEG_ENCBUF(buf)
local b = AEG_ENCBUF(bytes)Explicitly marks a byte buffer for protection.
AEG_OPAQUE(x)
local v = AEG_OPAQUE(input)Returns an opaque value the compiler cannot constant-fold away.
AEG_CRASH()
AEG_CRASH()Stops execution if reached - useful as a dead-code trap.
AEG_STACKALLOC(size)
AEG_STACKALLOC(16)Hints the obfuscator to reserve a scratch stack frame.
AEG_PRECHECK(cond, msg)
AEG_PRECHECK(x > 0, "bad x")Assertion helper that errors when the condition is false.
AEG_REWRITE()
AEG_REWRITE()Requests a control-flow rewrite of the enclosing scope.
AEG_LINE(n)
AEG_LINE(42)Source line marker (compatibility no-op).
AEG_NO_VIRTUALIZE(fn)
AEG_NO_VIRTUALIZE(function() ... end)Prevents virtualization of the marked function.
AEG_NO_OBFUSCATE(x)
AEG_NO_OBFUSCATE(value)Prevents any obfuscation of the marked value.
Need the full file? Download aegis.lua and include it at the top of your source.
Protected file header
Every encrypted file starts with a versioned Aegis header on line 1, a blank line 2, and your protected code from line 3 onward. The build number changes with each release.
-- This file was protected by Aegis Obfuscator Build 1.0.0 [https://aegisob.com] -- (your protected code starts here, line 3)
VM support matrix
| Closures & upvalues | Supported |
| Recursion | Supported |
| Method calls (a:b(...)) | Supported |
| Tables (array + dict) | Supported |
| Varargs (...) | Supported |
| Bitwise operators (& | ~ << >>) | Supported |
| Numeric for / while / repeat | Supported |
| break | Supported |
| Generic for ... in loops | Falls back to source mode |
| continue | Falls back to source mode |
| goto / labels | Falls back to source mode |
Tokens & plans
Encrypting one file costs 1 token (configurable). Get tokens by buying a plan or redeeming a key. Plans are monthly or one-time, each carrying a token amount and a buy URL - clicking Buy now sends you to the checkout URL the admin configured.
API options
| Option | Description |
|---|---|
| vm | Use the custom bytecode VM (strongest protection). |
| strings | Encrypt all string literals. |
| numbers | Obfuscate numeric literals. |
| flatten | Apply control-flow flattening. |
| rename | Rename locals and labels. |
| renameGlobals | Also rename globals (except preserved). |
| preserve | Array of globals to keep readable (AEG_* macros are always preserved). |
| seed | Fixed seed for reproducible output. |