News for hackers. Stuff that matters.
Re:Ruby Bug: SecureRandom should try /dev/urandom first by technion on Wednesday May 04, 2016 @01:17AM (#11626369)
This whole situation has annoyed me enough to start writing this gem:

https://github.com/technion/use_urandom

Note I said "start", so I'm aware it needs work. Feedback is appreciated however.

Re:Ruby Bug: SecureRandom should try /dev/urandom first by matthewrudy on Wednesday May 04, 2016 @02:09AM (#11626545)
I'd suggest you just use the `rescue` definition from SecureRandom.

Then you don't have to do any work yourself.

    def SecureRandom.gen_random(n)
      ret = Random.raw_seed(n)
      unless ret
        raise NotImplementedError, "No random device"
      end
      unless ret.length == n
        raise NotImplementedError, "Unexpected partial read from random device: only #{ret.length} for #{n} bytes"
      end
      ret
    end