1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-15 20:29:03 +00:00

Remove nearly all bit.lua use

This commit is contained in:
dmiller
2018-08-28 15:56:45 +00:00
parent e0af0179eb
commit 24c5ff63b2
21 changed files with 79 additions and 98 deletions

View File

@@ -1,4 +1,3 @@
local bit = require "bit"
local http = require "http"
local shortport = require "shortport"
local stdnse = require "stdnse"
@@ -131,12 +130,12 @@ local function phpass_encode64(input)
while cur < count do
local value = string.byte(input, cur)
cur = cur + 1
table.insert(out, itoa64(bit.band(value, 0x3f)))
table.insert(out, itoa64(value & 0x3f))
if cur < count then
value = bit.bor(value, bit.lshift(string.byte(input, cur), 8))
value = value | (string.byte(input, cur) << 8)
end
table.insert(out, itoa64(bit.band(bit.rshift(value, 6), 0x3f)))
table.insert(out, itoa64((value >> 6) & 0x3f))
if cur >= count then
break
@@ -144,16 +143,16 @@ local function phpass_encode64(input)
cur = cur + 1
if cur < count then
value = bit.bor(value, bit.lshift(string.byte(input, cur), 16))
value = value | (string.byte(input, cur) << 16)
end
table.insert(out, itoa64(bit.band(bit.rshift(value, 12), 0x3f)))
table.insert(out, itoa64((value >> 12) & 0x3f))
if cur >= count then
break
end
cur = cur + 1
table.insert(out, itoa64(bit.band(bit.rshift(value, 18), 0x3f)))
table.insert(out, itoa64((value >> 18) & 0x3f))
end
return table.concat(out)