Module: UseUrandom
- Defined in:
- lib/use_urandom.rb,
lib/use_urandom/version.rb
Constant Summary collapse
- URANDOM =
"/dev/urandom"- VERSION =
"0.1.0"
Class Method Summary collapse
Class Method Details
.urandom(n) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/use_urandom.rb', line 21 def self.urandom(n) device = ($urandom_file_test.nil?) ? URANDOM : $urandom_file_test fh = File.open device, 'rb' raise "Invalid urandom file" unless (fh.stat.uid == 0 && fh.stat.gid == 0) data = fh.read(n) raise "Not enough data read" unless data.size == n data end |