-- 将全局 SYMBOLS 字符串(192 字节)转换为表(64 个符号,每个 3 字节) local symbol_table = {} for i = 1, 64 do local start_byte = (i-1)*3 + 1 symbol_table[i] = SYMBOLS:sub(start_byte, start_byte+2) end SYMBOLS = symbol_table -- 现在 SYMBOLS 是表,可直接用数字索引 local BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" local function randChars(len) local chars = "abcdefghijklmnopqrstuvwxyz0123456789" local s = {} for i = 1, len do s[i] = chars:sub(math.random(#chars), math.random(#chars)) end return table.concat(s) end local function randSymbols(len) local s = {} for i = 1, len do s[i] = SYMBOLS[math.random(64)] -- 直接取表元素 end return table.concat(s) end -- 纯 Lua Base64 编码(字节级正确) local function b64Encode(str) local chars = BASE64_CHARS local len = #str local result = {} local i = 1 while i <= len do local b1 = str:byte(i) local b2 = str:byte(i+1) or 0 local b3 = str:byte(i+2) or 0 local n1 = math.floor(b1 / 4) local n2 = (b1 % 4) * 16 + math.floor(b2 / 16) local n3 = (b2 % 16) * 4 + math.floor(b3 / 64) local n4 = b3 % 64 result[#result+1] = chars:sub(n1+1, n1+1) result[#result+1] = chars:sub(n2+1, n2+1) if i+1 <= len then result[#result+1] = chars:sub(n3+1, n3+1) end if i+2 <= len then result[#result+1] = chars:sub(n4+1, n4+1) end i = i + 3 end local pad = (3 - (len % 3)) % 3 if pad == 1 then result[#result+1] = "=" elseif pad == 2 then result[#result+1] = "==" end return table.concat(result) end local function encryptLin(url) local r1 = randChars(8) local r2 = randChars(8) return "Lin" .. r1 .. r2 .. b64Encode(url) end local function encryptLinpro(url) local r1 = randSymbols(8) local r2 = randSymbols(8) local plain = url .. "||" local xored_bytes = {} for i = 1, #plain do xored_bytes[i] = string.char(plain:byte(i) ~ 0x5A) end local b64 = b64Encode(table.concat(xored_bytes)) local sym = {} for i = 1, #b64 do local ch = b64:sub(i, i) local idx = BASE64_CHARS:find(ch, 1, true) -- 返回 1~64 或 nil if idx then sym[#sym+1] = SYMBOLS[idx] -- 用表索引取符号 end end return "linpro" .. r1 .. r2 .. table.concat(sym) end local function Main() local sel = gg.choice({"免费版 Lin", "付费版 linpro", "退出"}, nil, "选择加密模式") if sel == nil or sel == 3 then return end local input = gg.prompt({"请输入Lua直链URL"}, {""}, {"text"}) if not input or input[1] == "" then gg.alert("内容不能为空") return end local url = input[1] local result if sel == 1 then result = encryptLin(url) else result = encryptLinpro(url) end local c = gg.choice({"复制文本", "关闭"}, nil, result) if c == 1 then gg.copyText(result) gg.alert("复制成功,请粘贴到 MT 管理器或浏览器查看符号") end end Main()