file = {} function file.exists(FilePath) local file = io.open(FilePath, "r") if file then file:close() return true end return false end function file.write(FilePath, Content) local file = io.open(FilePath, "w") if file then file:write(Content) file:close() return true end return false end function file.read(FilePath) local file = io.open(FilePath, "r") if file then local Content = file:read("*all") file:close() return Content end return nil end function StringVariableConfusion() local Prompt = gg.prompt({'输入需要混淆的文件路径'}, {FHStringVariableConfusionFilePath}, {'file'}) if not Prompt then gg.toast('输入框被取消') return end file.write(FHStringVariableConfusionFilePath_Config, FHStringVariableConfusionFilePath) local input_file = Prompt[1] local output_file = Prompt[1]..'[字符串变量混淆].lua' local file = io.open(input_file, "r") if not file then gg.alert("未能打开文件:" .. input_file) return end local content = file:read("*a") file:close() local variables = {} local processed_content = content local count = 0 for quote, str in string.gmatch(content, "(['\"])(.-)%1") do count = count + 1 local var_name = "text._" .. count variables[#variables + 1] = var_name .. ' = "' .. str .. '"' processed_content = processed_content:gsub(quote .. str .. quote, var_name) end local output_content = 'text = {}\n' .. table.concat(variables, "\n") .. "\n\n" .. processed_content local output_file_handle = io.open(output_file, "w") if output_file_handle then output_file_handle:write(output_content) output_file_handle:close() gg.alert("成功混淆文件\n路径: " .. output_file) else gg.alert("输出文件失败"..output_file) end end function switch() if FHStringVariableConfusionFilePath == nil then FHStringVariableConfusionFilePath = '/storage/emulated/0/' end FHStringVariableConfusionFilePath_Config = '/storage/emulated/0/FuHong/configurations/.FHStringVariableConfusion/FHStringVariableConfusion_FilePath.json' if file.exists(FHStringVariableConfusionFilePath_Config) then FHStringVariableConfusionFilePath = file.read(FHStringVariableConfusionFilePath_Config) end UI = { '[ - ]打开字符串全局变量混淆', '[ - ]退出字符串全局变量混淆' } alert = gg.choice(UI,nil,'代码字符串全局混淆加密工具\n最近一次混淆的脚本路径:'..FHStringVariableConfusionFilePath) if alert == 1 then StringVariableConfusion() return end if alert == #UI then print('\nFHStringVariableConfusionTool Exit\n源码零售价:10RMB') FuHongTool_Break = true end end gg.setVisible(true) while true do if FuHongTool_Break then FuHongTool_Break = false break end if gg.isVisible(true) then gg.setVisible(false) switch() end end