# MoonSec Obfuscator Macros

## Encrypt a string:

If you want to encrypt a specific string, use this macro. Just add "ENCRYPT:" in a string as a prefix.

```lua
local str1 = "ENCRYPT:Hi LOL"
local str2 = [[ENCRYPT:Whats good?]]
local api = game:HttpGet("ENCRYPT:https://f3d.at")
local a = [[ENCRYPT:
Multiline
thing]]
```

## Exclude string from encryption:

If you want to encrypt all strings but a specific one, include 'NO\_ENCRYPT:' in the string.

```lua
local c = "NO_ENCRYPT:Hello there";
local f = [[NO_ENCRYPT:Hello world!]]
local x = 'NO_ENCRYPT:Hello!';
local s = [[NO_ENCRYPT:
Multiline
string
]]
```

{% hint style="warning" %}
&#x20;Strings smaller than 4 characters or longer than 512 characters will not be encrypted.
{% endhint %}

## Get decrypted string table: GetDST(\<void>)

Returns the table that stores decrypted strings. This can be used for debugging purposes or to modify a string directly from the script.

```lua
table.foreach(GetDST(), print)

for i,v in pairs(GetDST()) do
    if v == "Hello world" then
        GetDST()[i] = "New value"
    end
end

```

## EQ Macro: \_\_secureeq(variable1, variable2)

This macro is still under development and currently not public, but here is the usage.&#x20;

This macro encrypts the if-else statement and decrypts it only if statement actually equals true, therefore stops  JMP / EQ hooking based attacks to crack whitelist systems.

{% hint style="danger" %}
This macro is under development, if you use it now, it will act like a regular \_\_eq.
{% endhint %}

```lua
local WhitelistedHWID = "abcd1234" -- example string 1
local MyHWID = Player:GetHWID() -- example string 2

if __secureeq(MyHWID, WhitelistedHWID) then
    print("Authorized")
end

if __secureeq("1244", "12".."44") then
    print("Equals")
end

if __secureeq(nil, 7) then
    print("No way")
end
```

{% hint style="warning" %}
You **shouldn't** use any "or" operator to connect multiple statements while using **secureeq** macro. If one side equals true, it will cause strings to stay encrypted and **break your code.**
{% endhint %}

{% hint style="warning" %}
You **shouldn't** assign or overwrite secureeq function. You can still use it as == operator but it will not have extra security if you use it outside an if-else statement. (e.g local test = \_\_secureeq(1,2))
{% endhint %}
