Lua Base64编码

我不使用 Lua,并尝试在互联网上搜索,这个语句是做什么的:

assert`(load(Base64Decode(==BASE64 Script but is not Encoded like usualy==), nil, "bt", _ENV))().`

每个编码信息以 G0x........== 开头。我尝试了数学解码,但我无能为力。

所以,需要帮助吗?

点赞
用户4509141
用户4509141

很容易在谷歌上找到解决方案。连续提问可能会导致暂时的“询问禁用”,这时你将不能提问。我们可能需要更多的信息,但是从标题来看,我想你想要从Base64编码和解码。来源:[lua-users wiki: Base64](http://lua-users.org/wiki/BaseSixtyFour):

local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- 编码/解码时需要用到
-- 编码
function enc(data)
    return ((data:gsub('.', function(x)
        local r,b='',x:byte()
        for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
        return r;
    end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
        if (#x < 6) then return '' end
        local c=0
        for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
        return b:sub(c+1,c+1)
    end)..({ '', '==', '=' })[#data%3+1])
end

-- 解码
function dec(data)
    data = string.gsub(data, '[^'..b..'=]', '')
    return (data:gsub('.', function(x)
        if (x == '=') then return '' end
        local r,f='',(b:find(x)-1)
        for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
        return r;
    end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
        if (#x ~= 8) then return '' end
        local c=0
        for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
            return string.char(c)
    end))
end

这应该会有帮助。 ~TheCrimulo

2016-02-09 22:19:41