_ENV['算法'] = function (num) local match = tonumber(num) local rom = math.random(1, 10) if math.random() < 0.35 then local chr = match - rom return '(' .. chr .. '+' .. rom .. ')' else local chr = match + rom return '(' .. chr .. '-' .. rom .. ')' end end function hx(inputString) local result = '' for i = 1, #inputString do local charCode = inputString:byte(i) if result ~= '' then result = result .. ',' end result = result .. tostring(charCode) end return 'string.char(' .. result .. ')' end function enc(code) local code = hx(code) local cx_1 = string.gsub(code,'%d+',_ENV['算法']) return cx_1 end function StringCode (dqy) dqy = string.gsub(dqy, '\39(.-)\39', enc) dqy = string.gsub(dqy, '\34(.-)\34', enc) return dqy end function fileExists(FilePath) local file = io.open(FilePath, "r") if file then file:close() return true end return false end function StringEncryption(Mode) if Mode == 'File' then Prompt = gg.prompt({'请选择需要加密的脚本'},{FHStringEncryptionFilePath},{'file'}) if not Prompt then gg.toast('输入框被取消') return gg.setVisible(true) end if Prompt then if fileExists(Prompt[1]) == false then gg.alert2('错误', '没有指定路径的目标['..Prompt[1]..']', '取消') return end code = io.open(Prompt[1],'r'):read('*a') local loadingBox = getLoadingBox('正在字符串混淆加密脚本..\n'..Prompt[1]) loadingBox['显示']() code = StringCode(code) loadingBox['关闭']() io.open(Prompt[1]..'[字符串混淆].lua','w'):write(code) file.write(FHStringEncryptionFilePath_Config,Prompt[1]) gg.alert2('加密成功','加密后的文件保存在:\n'..Prompt[1]..'[字符串混淆].lua','好') end end if Mode == 'Customize' then Prompt = gg.prompt({'请选择需要加密的内容'},{'示例'},{'text'}) if not Prompt then gg.toast('输入框被取消') return gg.setVisible(true) end if Prompt then local loadingBox = getLoadingBox('正在字符串混淆加密内容..\n'..Prompt[1]) loadingBox['显示']() Code = enc(Prompt[1]) loadingBox['关闭']() Alert = gg.alert2('加密成功','加密内容:\n'..Code,'取消','复制','导出') if not Alert or Alert == 1 then gg.toast('选择框被取消') return gg.setVisible(true) end if Alert == 2 then gg.copyText(Code) gg.toast('已复制内容'..Code..'\n部分设备复制可能会出现缺少,符号的情况 如缺少,请使用导出') end if Alert == 3 then Temp_Path = '/storage/emulated/0/'..os.time()..'[字符串混淆].txt' file.write(Temp_Path,Code) gg.alert2('导出成功','内容已导出至路径:'..Temp_Path,'好') end end end end function switch() if FHStringEncryptionFilePath == nil then FHStringEncryptionFilePath = '/storage/emulated/0/' end FHStringEncryptionFilePath_Config = '/storage/emulated/0/FuHong/configurations/.FHStringEncryption/FHStringEncryption_FilePath.json' if file.exists(FHStringEncryptionFilePath_Config) then FHStringEncryptionFilePath = file.read(FHStringEncryptionFilePath_Config) end UI = { '[ - ]打开字符串加密', '[ - ]自定字符串加密', '[ - ]退出字符串加密' } alert = gg.choice(UI,nil,'代码字符串加密工具\n最近一次加密的脚本路径:'..FHStringEncryptionFilePath) if alert == 1 then StringEncryption('File') return end if alert == 2 then StringEncryption('Customize') end if alert == #UI then print('\nFHStringEncryptionTool Exit') 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