How can I run bitwise operations in Openresty? AFAIK, luajit supports the bit32 table, yet the following code does not work:
str = "8.8.8.8"
o1,o2,o3,o4 = str:match("(%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)" )
num = 2^24*o1 + 2^16*o2 + 2^8*o3 + o4
for i=1,32 do
ngx.say(ngx.ERR, bit32.lrotate(bit32.arshift(num, i),i))
end
The error message is:
attempt to index global 'bit32' (a nil value)
thanks
- G