0

Reading through the Ruby Doc 2.3.0 which states the strategy that Ruby code uses to generate a Random Number.

  • openssl
  • /dev/urandom
  • Win32

But looking 2.3.0 Source I don't see any sign of /dev/urandom be used.

Atleast 2.2.2 has /dev/urandom logic.

Please correct me if I'm wrong. I'm just helping myself understand how does random number are generated in Ruby.

Viren
  • 5,812
  • 6
  • 45
  • 98

1 Answers1

0

You have to look at the Random.raw_seed implementation which can be found in random.c.

And since the docs don't mention it: before trying to read from /dev/urandom the code tries to call getrandom(2) on recent Linux versions (see fill_random_bytes()).

cremno
  • 4,672
  • 1
  • 16
  • 27