How can I create a variable in size of specific number of bytes in lua?

238 Views Asked by At

How can I create a variable that will contain for example 24 bytes of zeros in lua? I thought about something like: local zeros = "0X0000..00" (with 24 zeros).

And in addition, how can I create a variable that will be in size of 8 bytes?

1

There are 1 best solutions below

2
koyaanisqatsi On

All strings have string library functions attached as methods.
Therefore theres a simpel Answer...

$ lua
Lua 5.4.4  Copyright (C) 1994-2022 Lua.org, PUC-Rio
> Z24 = ('0'):rep(24)
> Z8 = ('0'):rep(8)
> #Z24
24
> #Z8
8
> Z24
000000000000000000000000
> Z8
00000000
> Z24 + Z8
0
> Z24 .. Z8
00000000000000000000000000000000
>