String Encoder V2
Key Required VerifiedUniversal

String Encoder V2

Universal Scriptvxstyvxsty 51.1K views 375 executesUpdated Feb 2, 2025
1.0/ 5(25 votes)
52020% Positive
Lua Script•130 lines (3511 chars)
--print(("\n"):rep(100))
--^ string library functions

local gmatch, sub, gsub, format, char, byte = string.gmatch, string.sub, string.gsub, string.format, string.char, string.byte
local uchar, ucode, upattern = utf8.char, utf8.codepoint, utf8.charpattern

local tostring, tonumber = tostring, tonumber
local tinsert = table.insert

local floor, clamp, random = math.floor, math.clamp, math.random
local bit32_bxor = bit32.bxor

local LuaEscapeCodes = {
    ["b"] = "\b",
    ["n"] = "\n",
    ["r"] = "\r",
    ["t"] = "\t",
    ["f"] = "\f",
    ["v"] = "\v",
    ["\""] = "\"",
    ["'"] = "\'",
    ["\\"] = "\\",
}

local Quotes = {
    ['"'] = "'",
    ["'"] = "\""
}

local function ParseStrings(File, ByteLength)
    local function ParseString(String) -- Formats the \u{...}, \f, \b, ...
        String = gsub(String, "\\(.)", function(Character)
            return LuaEscapeCodes[Character]
        end)
        String = gsub(String, "\\u{([0-9A-Fa-f]+)}", function(Hex)
            return uchar(tonumber(Hex, 16))
        end)

        return String
    end

    local Crypt = {
        Encoded = {}, -- Dictionary
        Used = {}, -- Array
        CharLen = ByteLength or random(4, 7) -- Byte length
    };

    function Crypt:GenerateKey(len)
        len = len or 64

        local key = "";
        local hex = {"a", "b", "c", "d", "e", "f", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}

        for _ = 1, len do
            key = key .. hex[random(1, #hex)]
        end

        return key
    end

    function Crypt:Encode(String, Quote)
        local Encoded = ""

        String = gsub(String, Quote, "\\" .. Quote)
        String = ParseString(String)

        for Char in gmatch(String, upattern) do
            local Generated = Crypt:GenerateKey(Crypt.CharLen) .. Crypt:GenerateKey(Crypt.CharLen)

            Crypt.Encoded[Char] = Crypt.Encoded[Char] or Generated

            Encoded = Encoded .. (Crypt.Encoded[Char])
        end

        return Encoded
    end

    function Crypt:GetList()
        local List = Crypt.Encoded;
        local String = "{\n"

        for Char, Value in next, List do
            Value = gsub(Value, "'", "\\'")

            String = String .. format("\t\t['%s'] = uchar(0x%02x);\n", Value, ucode(Char))
        end

        return String .. "\t}"
    end

    Crypt.FunctionCode = [[do ({})[1] = "ENCODED VIA STRING ENCODER V2.0, Please do not remove these credits." end
local uchar = utf8.char

local function %s(String)
    local A = String:gsub("%s", %s)
    return A;
end
]]

    Crypt.FunctionName = "_" .. Crypt:GenerateKey(8);

    --& Important Variables

    local Pattern = "%s([^%s]*)%s" -- %s is quote

    for N, Quote in next, Quotes do
        --local QuotePattern = format(Pattern, Opposing, Quote, Quote, Opposing, Quote)
        local QuotePattern = format(Pattern, Quote, Quote, Quote)
        local NQuotePattern = format(Pattern, N, N, N)

        local function Inner(String)
            if String == "" then
                return
            end

            String = gsub(String, NQuotePattern, function(String2)
                return N .. String2 .. N
            end)

            return format("%s([[%s]])", Crypt.FunctionName, Crypt:Encode(String, Quote))
        end

        File = gsub(File, QuotePattern, Inner)
    end

    return format(Crypt.FunctionCode, Crypt.FunctionName, string.rep(".", Crypt.CharLen * 2), Crypt:GetList()) .. File
end

local Code2 = ParseStrings('print("Hello World!")', 4)
print(Code2)

Features & Information

Protect strings from obfuscator constant dumps at the cost of performance. You need to prevent string.gsub & utf8.char hooks, Otherwise this is pretty much pointless, (Prevent those hooks so that when the script is ran, they cannot just get all the strings). Make sure the encoded version is obfuscated, with the antihooks. Usage: local ByteLength = 4 -- How many bytes each character should be, recommend 3-6 writefile("encoded.lua", ParseStrings(readfile("rawtext.lua")), ByteLength)
#StringEncoder#Universal#Free

Community Comments (9)

BigBlue_ScripterBigBlue_ScripterFeb 2, 2025(edited)

ty

SimpleScripterSimpleScripterFeb 2, 2025(edited)

Hey 👋! Where do I put it 😁

vxstyvxstyFeb 2, 2025(edited)

@SimpleScripter Read the usage, put the example usage script under the script

Al_ibiAl_ibiFeb 2, 2025(edited)

Pretty good works well

wesdfrwesdfrFeb 17, 2025(edited)

ud

ReactorCoreDevReactorCoreDevMay 1, 2025

chatgpt: dont worry i gotchu the string is "Hello World!"

Replying to @ReactorCoreDev
environmentenvironmentAug 25, 2025

@ReactorCoreDev it's not supposed to be 100% chatgpt proof, it's designed to to encode strings and make it harder to understand at first glance

Replying to @environment
helloworld39429helloworld39429Sep 2, 2025

@4774 bud he didn't say it was gpt he said its easy to decode lmao

vxstyvxstySep 2, 2025

@helloworld39429 the point is to encode strings, to hide them from constant dumps & deobfuscations, not read the code.

More Scripts for Universal Scripts