Grayda
Grayda

Reputation: 2150

Converting bytes to table in Lua doesn't work in 5.2.4

I'm writing a dissector for Wireshark, and want to use aeslua to decrypt some packets that are coming in. My dissector works fine, but aeslua gets caught up on a line that tries to put the password into a table after converting it to bytes.

The line in question is this:

local pwBytes = { string.byte(password,1,#password)}

This returns null in Lua 5.2.4 (which is included in Wireshark 2.2.4), but in the online demo (2.3.4 as of writing), it returns the expected value.

I tried changing it to:

local pwBytes = { password:byte(1, #password) }

But got the same null result.

For reference, he's the code I ran in the Lua demo:

local password = "ABCDEFABCDEFA"
local pwBytes = {string.byte(password,1,#password)}
print(pwBytes)

Is there a way I get around this?

Upvotes: 0

Views: 343

Answers (1)

lhf
lhf

Reputation: 72312

The code works fine in stock Lua 5.2.4:

local password = "ABCDEFABCDEFA"
local pwBytes = {string.byte(password,1,#password)}
print(pwBytes)
for k,v in ipairs(pwBytes) do
  print(k,v)
end

gives

table: 0x7fc689d00560
1   65
2   66
3   67
4   68
5   69
6   70
7   65
8   66
9   67
10  68
11  69
12  70
13  65

Upvotes: 1

Related Questions