module UseUrandom
Constants
- VERSION
Public Class Methods
urandom(n)
click to toggle source
Reads 'n' bytes from URANDOm
# 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