<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="18">
  <Files>
    <enctbl Encoding="Ascii85">C5}GT12G5#[dxTpKmy?xRj:4Ht:URMay.hoyRPeFNjr?-E4e8nB^_6neB.huw8#tH#xx7PVX82C%;WNJwJ2.FvPk)Vg;%N%Kk1[twi,5W,U4J8mgt/Smo=^g/}D[rC9Uo25KU^_)f:M8LGJGZ</enctbl>
  </Files>
  <CheatEntries>
    <CheatEntry>
      <ID>0</ID>
      <Description>"test me :D"</Description>
      <LastState Activated="0"/>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{$lua}
if syntaxcheck==true then return '' end
--

--


-- common function
function loadTableFile(n,mode)
  local hdr = 'loadTableFile: '
  assert(type(n)=='string',hdr.."input should be a string -"..tostring(n).." of "..type(n))
  local m = assert(findTableFile(n),hdr.."can't find table file -"..n).Stream
  m = assert(readStringLocal(m.Memory,m.Size),hdr.."can't read content -"..n)
  if type(mode)~='boolean' then return m end
  m = assert(loadstring(m,n),hdr.."lua script load fail -"..n)
  return mode and m() or m
end

function enc(s,k,infile,outfile) -- this can be not include on releasing trainer/table, but ok to include
  if type(k)~='string' then return nil,'?ERROR?' end
  if type(infile)=='string' then
    local ok,f = pcall(io.open,infile,'r')
    print(tostring(ok),tostring(f))
    if ok and f then
      print("reading:",infile)
      s = f:read("*a")
      f:close()
    end
  elseif findTableFile(s or '') then
      s = loadTableFile(s)
  end
  if type(s)~='string' then return nil,'?ERROR?' end

  k = stringToMD5String(k)
  local kt,t,i,j = {},{},1
  while k:byte(i) do kt[1+#kt]=k:byte(i) i=i+1 end
  i=1
  while s:byte(i) do
    j = 1+((i-1) % #kt)
    t[1+#t]= bAnd(bXor(kt[j],s:byte(i)),0xff)
    i = i+1
  end
  t = #t&gt;0 and "{"..table.concat(t,",").."}" or '{}'
  if type(outfile)=='string' then
    local ok,f = pcall(io.open,outfile,'w')
    print(tostring(ok),tostring(f))
    if ok and f then
      f:write(t)
      f:close()
      print("writen:",outfile)
    end
  end
  return t
end

function dec(t,k)
  if type(t)~='string' or type(k)~='string' then return nil,'*ERROR*' end
  k = stringToMD5String(k)
  local fs = "return "..t
  local kt,i = loadstring(fs),1
  local ok
  if type(kt)=='function' then ok,t = pcall(kt) end
  if not ok or type(t)~='table' then return nil,'!ERROR!' end
  kt = {}
  while k:byte(i) do kt[1+#kt]=k:byte(i) i=i+1 end
  local s,j = {}
  for i=1,#t do
    j=1+((i-1) % #kt)
    s[1+#s]= string.char(bAnd(bXor(kt[j],t[i]),0xff))
  end
  return table.concat(s)
end

--- do not ship your train/table with the real password
--- do not ship your train/table with the real password
--- do not ship your train/table with the real password
--- do not ship your train/table with the real password
local coreSource = "Ok, you got the explict password from source, well done!!! ;) now try the hidden one :D"
local password   = "ce"
--- do not ship your train/table with the real password
--- do not ship your train/table with the real password
--- do not ship your train/table with the real password
--- do not ship your train/table with the real password




--- sample code to make encoded tablefile
--- sample code to make encoded tablefile
--- sample code to make encoded tablefile
--- sample code to make encoded tablefile
--enc(nil,"no-this-is-not-password-:D",[[mysource.lua]],'enctbl')
--- sample code to make encoded tablefile
--- sample code to make encoded tablefile
--- sample code to make encoded tablefile
--- sample code to make encoded tablefile

local enSource = enc(coreSource,password) -- replace this as " loadTableFile('enctbl') " like ==ENCODE== below

function r(psw)
  print('')
  print('')
  -- explict source password is 'ce'
  local deSource = dec(enSource,psw)

  print("Explict Source:\n")
  print( deSource)

  deSource = dec(loadTableFile('enctbl'),psw)   --  ==ENCODE==

  -- this one is runnable
  print("Hidden Source:\n")
  local ok,runnable = pcall(loadstring,deSource)
  if ok and type(runnable)=='function' and runnable() == 'I-NEVER-LIE' then
    print("Good! you crack the hidden source!")
  end
  print(  deSource)
end

r(inputQuery("Password","Enter Password&gt;","cancel to pretent you know the password ;)") or password)

{$asm}
[ENABLE]
[DISABLE]
</AssemblerScript>
    </CheatEntry>
  </CheatEntries>
  <UserdefinedSymbols/>
</CheatTable>
