Neon Flash
Neon Flash

Reputation: 3233

Generating Random numbers with a known seed value

I am debugging a 64-bit Linux ELF binary which uses time() to generate a seed. Then this seed is used by srand() to seed the random number generator. And rand() is used to generate the random number.

I have the value of the seed and now I am trying to reproduce the same result as the binary.

seed = 0x93ae5c6

srand(seed)

rand() returns 0x000000003173C91C

If I use Python to generate the random number, I get a different result

import random
random.seed(0x93ae5c6)
random.random() returns 0.8019104241491927

Is it because Python generates random numbers in a different way than glibc on Linux?

Upvotes: 0

Views: 414

Answers (1)

Alex Python
Alex Python

Reputation: 327

Try this
Python port of the GLIBC rng

Upvotes: 3

Related Questions