3 ms·
This whole situation has annoyed me enough to start writing this gem: https://github.com/technion/use_urandom https://github.com/technion/use_urandom Note I s
by technion 11y ago
This whole situation has annoyed me enough to start writing this gem:
https://github.com/technion/use_urandom https://github.com/technion/use_urandom
Note I said "start", so I'm aware it needs work. Feedback is appreciated however.
- matthewrudy 11y agoI'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