import React, { useState } from 'react'; export default function LuaObfuscator() { const [input, setInput] = useState(`-- Paste your Lua code here\nprint("Hello from Lua")`); const [output, setOutput] = useState(''); const [message, setMessage] = useState(''); // Base64 encode that supports Unicode function base64EncodeUnicode(str) { try { // encodeURIComponent -> percent-encoding -> unescape -> btoa safe for Unicode return btoa(unescape(encodeURIComponent(str))); } catch (e) { // fallback using TextEncoder const bytes = new TextEncoder().encode(str); let binary = ''; bytes.forEach((b) => (binary += String.fromCharCode(b))); return btoa(binary); } } // charset from user-provided decoder const bchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function randomJunk(len = 55) { let out = ''; const l = bchars.length; for (let i = 0; i < len; i++) out += bchars[Math.floor(Math.random() * l)]; return out; } function makeWrapper(payload) { // Keep the user-supplied decoder function intact (as given) then insert payload and execute it // We will produce a final .lua file that defines the decoder, the data string, decodes it, then executes. return `local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfunction qjMwwlHbImAHSydlJwFezbeFGkwOuaLFpZVH(data) m=string.sub(data, 0, 55) data=data:gsub(m,'')\n\ndata = string.gsub(data, '[^'..b..'=]', '') return (data:gsub('.', function(x) if (x == '=') then return '' end local r,f='',(b:find(x)-1) for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end return r; end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x) if (#x ~= 8) then return '' end local c=0 for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end return string.char(c) end)) end\n\nlocal data = '${payload}'\nlocal decoded = qjMwwlHbImAHSydlJwFezbeFGkwOuaLFpZVH(data)\nif type(decoded) == 'string' then\n local fn, err = load(decoded)\n if fn then\n pcall(fn)\n else\n error('Failed to load decoded chunk: '..tostring(err))\n end\nelse\n error('Decoder did not return a string')\nend`; } function obfuscate() { setMessage(''); try { const b64 = base64EncodeUnicode(input); const junk = randomJunk(55); const payload = junk + b64; const wrapped = makeWrapper(payload); setOutput(wrapped); setMessage('Obfuscation complete — copy or download the .lua file.'); } catch (err) { setMessage('Error during obfuscation: ' + String(err)); } } function copyOutput() { if (!output) return setMessage('Nothing to copy'); navigator.clipboard.writeText(output).then(() => setMessage('Copied to clipboard!')) .catch(() => setMessage('Copy failed — your browser may block clipboard access')); } function downloadLua() { if (!output) return setMessage('No output to download'); const blob = new Blob([output], { type: 'text/plain;charset=utf-8' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'obfuscated.lua'; document.body.appendChild(a); a.click(); a.remove(); URL.revokeObjectURL(url); setMessage('Download started'); } function clearAll() { setInput(''); setOutput(''); setMessage('Cleared'); } return (
Paste your Lua source on the left — this tool will wrap it using the provided decoder function, base64-encode it, prepend 55 bytes of random junk (so the decoder's prefix-removal behaves), and produce a runnable obfuscated .lua file on the right.
The result is a self-contained .lua file that uses the supplied decoder function and runs your original code.