首页 > 编程知识 正文

怎么把这段php代码写成lua(编写一个php程序)

时间:2023-12-23 21:12:48 阅读:319412 作者:FIHG

本文目录一览:

怎么把这段php代码写成lua

base64需要自己找个库调用一下,其他部分实现了,下面是代码

local function decode(str, skey) str = str or "" skey = skey or "cxphp" local replaceStr = string.gsub(str, "O0O0O", "=") replaceStr = string.gsub(replaceStr, "o000o", "+") replaceStr = string.gsub(replaceStr, "oo00o", "/") local strArr = {} local replaceStrLen = string.len(replaceStr) for pos = 1, replaceStrLen, 2 do local posEnd = math.min(pos + 1, replaceStrLen) strArr [#strArr + 1] = string.sub(replaceStr, pos, posEnd) end local strCount = #strArr for key = 1, string.len(skey) do local value = string.sub(skey, key, key) print(key, value, strArr[key], string.sub(strArr[key], 2, 2)) if key = strCount and strArr[key] and string.sub(strArr[key], 2, 2) == value then strArr[key] = string.sub(strArr[key], 1, 1) end end local needToDecode = table.concat(strArr) print(needToDecode) -- TODO: find a lib base64_decodeend

怎么把下面php代码换成lua

local function decode(str, skey)

   str = str or ""

   skey = skey or "cxphp"

   local replaceStr = string.gsub(str, "O0O0O", "=")

   replaceStr = string.gsub(replaceStr, "o000o", "+")

   replaceStr = string.gsub(replaceStr, "oo00o", "/")

   local strArr  = {}

   local replaceStrLen = string.len(replaceStr)

   for pos = 1, replaceStrLen, 2 do

      local posEnd = math.min(pos + 1, replaceStrLen)

      strArr [#strArr + 1] = string.sub(replaceStr, pos, posEnd)

    end

   local strCount = #strArr

   for key = 1, string.len(skey) do

      local value = string.sub(skey, key, key)

      print(key, value, strArr[key], string.sub(strArr[key], 2, 2))

      if key = strCount and strArr[key] and string.sub(strArr[key], 2, 2) == value then

         strArr[key] = string.sub(strArr[key], 1, 1)

      end

   end

   local needToDecode = table.concat(strArr)

   print(needToDecode)

   -- TODO: find a lib base64_decode

end

怎么把如下php代码写成lua代码?

base64需要自己找个库调用一下,其他部分实现了,下面是代码

local function decode(str, skey)

   str = str or ""

   skey = skey or "cxphp"

   local replaceStr = string.gsub(str, "O0O0O", "=")

   replaceStr = string.gsub(replaceStr, "o000o", "+")

   replaceStr = string.gsub(replaceStr, "oo00o", "/")

   local strArr  = {}

   local replaceStrLen = string.len(replaceStr)

   for pos = 1, replaceStrLen, 2 do

      local posEnd = math.min(pos + 1, replaceStrLen)

      strArr [#strArr + 1] = string.sub(replaceStr, pos, posEnd)

    end

   local strCount = #strArr

   for key = 1, string.len(skey) do

      local value = string.sub(skey, key, key)

      print(key, value, strArr[key], string.sub(strArr[key], 2, 2))

      if key = strCount and strArr[key] and string.sub(strArr[key], 2, 2) == value then

         strArr[key] = string.sub(strArr[key], 1, 1)

      end

   end

   local needToDecode = table.concat(strArr)

   print(needToDecode)

   -- TODO: find a lib base64_decode

end

php字符串转成可执行代码

echo htmlentities($str);

不能了,因为手册里有的〈?PHP ?〉i不能被套的。故不能。我刚才又查了一番。

你可以用此法:

用include('文件路径及文件名');

$a = '? echo 11111;?';

$a = str_replace(array('?', '?'), '', $a);

eval($a);

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。