I need get little endian random string via python.
Such as '0010' as 256 (without '\x')
Here is my code.
import random
import struct
str1 = struct.pack('<Q', random.randint(1, 1000))
#Ex: str1 = '\xc9\x02\x00\x00\x00\x00\x00\x00'
But I don't have any idea to convert this string to "C902000000000000" Please give any advise, thanks
Another alternative, which is quite easy to type, is the following approach:
>>> import random
>>> import struct
>>> str1 = struct.pack('<Q', random.randint(1, 1000))
>>> str1.encode('hex')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With