--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)