Module: UseUrandom
- Defined in:
- lib/use_urandom.rb,
lib/use_urandom/version.rb
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
-
.urandom(n) ⇒ Object
Reads ānā bytes from URANDOm.
Class Method Details
.urandom(n) ⇒ Object
Reads ānā bytes from URANDOm
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/use_urandom.rb', line 26 def self.urandom(n) # Facilitates testing fh = File.open SecureRandom::URANDOM, 'rb' # Sanity test - owned by root raise "Invalid urandom file" unless (fh.stat.uid == 0 && fh.stat.chardev?) data = fh.read(n) fh.close raise "Not enough data read" unless data.size == n data end |