First time here? Check out the FAQ!
THIS IS A TEST INSTANCE. Feel free to ask and answer questions, but take care to avoid triggering too many notifications.
0

LUA and bignum

  • retag add tags

Hello,

is it possible for LUA dissector to convert 8x bytes to its decimal/string equivalence ?

local input="00007048860ddf75"
local output = tostring(tonumber(input,16))

expected: 123456789012341
but got: 1.2345678901234e+14

I understand this is normally overcome with some bignum library (ie: bc.dll) but not sure it can work within dissector sandbox.

Any idea ?

Thx, A.

sezb51's avatar
9
sezb51
asked 2021-09-10 20:30:35 +0000
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

Take a look at the documentation at: https://www.wireshark.org/docs/wsdg_h...

11.13.1.5. Int64.fromhex(hex)
Creates an Int64 object from the given hexadecimal string.

André's avatar
176
André
answered 2021-09-10 21:27:35 +0000
edit flag offensive 0 remove flag delete link

Comments

Works like a charm!

local input="00007048860ddf75"
local output = Int64.fromhex(input)

it does produces now: 123456789012341

I think I may refactor few things with Int64 now :)

Thank you! A.

sezb51's avatar sezb51 (2021-09-11 06:45:51 +0000) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer