Ask Your Question

LUA and bignum

asked 2021-09-10 20:30:35 +0000

sezb51 gravatar image


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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2021-09-10 21:27:35 +0000

André gravatar image

Take a look at the documentation at: Int64.fromhex(hex)
Creates an Int64 object from the given hexadecimal string.

edit flag offensive delete link more


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 gravatar imagesezb51 ( 2021-09-11 06:45:51 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-09-10 20:30:35 +0000

Seen: 142 times

Last updated: Sep 10 '21