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
https://github.com/technion/use_urandom
Note I said "start", so I'm aware it needs work. Feedback is appreciated however.