是否可以隐藏Lua编译代码中的字符串?

时间:2018-03-12 11:00:37

标签: string lua obfuscation luac

我的代码中指定为字符串的文件的路径,并且我不希望在luac转换后可见。是否有可能混淆这条线? 我的代码是:

DIR1 = '../../../files/file1.txt'

谢谢!

1 个答案:

答案 0 :(得分:2)

示例:

local Key53 = 8186484168865098
local Key14 = 4887

function decode(str)
   local K, F = Key53, 16384 + Key14
   return (str:gsub('%x%x',
      function(c)
         local L = K % 274877906944   -- 2^38
         local H = (K - L) / 274877906944
         local M = H % 128
         c = tonumber(c, 16)
         local m = (c + (H - M) / 128) * (2*M + 1) % 256
         K = L * F + H + c + m
         return string.char(m)
      end
   ))
end

local path = decode"beb81858c47a5fc7e11721921fb7f58ceeb530c4e74034df"
print(path)  -->  ../../../files/file1.txt

How to encode your own text