(25.12.2020, 13:49)admin Wrote: This code requires LuaJIT. It won't work with standard Lua because it does not have FFI library.
Can I assume an alternative Lua library (or libraries) could be used ?
For example to get around the encdec.base64dec() requirement, I used a base64 function/code from here - http://lua-users.org/wiki/BaseSixtyFour and added a specific new function called encdec_base64dec()
Code:
-- decoding
function encdec_base64dec(data)
local b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
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
I would really appreciate any guidance on alternatives for other calls such as those below e.g hex to/from string and aes_cbc encrypt/decrypt etc.
Code:
lmcore.strtohex(decrypted)
lmcore.hextostr('15C95AC2B08AA7EB4E228F811E34D04FA54BA7DCAC9879FA8ACDA3FC244F3854', true)
aes_cbc:decrypt(encdec.base64dec(data))
aes_cbc:encrypt(payload)
encdec.hmacsha256(ciphertext, hmac_key, true)
Is something like https://github.com/somesocks/lua-lockbox or something similar potentially a viable alternative library?