3 ms·
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
by matthewrudy 10y ago
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