class RealRand::EntropyPool

Public Class Methods

new() click to toggle source
Calls superclass method RealRand::OnlineGenerator::new
# File lib/random/online.rb, line 209
def initialize
  super("random.hd.org")
end

Public Instance Methods

randbyte(nbytes = 16, limit = true) click to toggle source
# File lib/random/online.rb, line 213
def randbyte(nbytes = 16, limit = true)
  if nbytes < 0 || nbytes > 256
    raise RangeError, "Invalid amount: #{nbytes}."
  end
  return [] if nbytes == 0
  parameters = "numBytes=#{nbytes}&type=bin&limit=#{limit}"
  response = get_response("/getBits.jsp", parameters)
  if response['content-type'] !~ /application\/octet-stream/
    raise "Unexpected content type: <#{response['content-type']}>."
  end
  result = []
  response.body.each_byte { |b| result << b }
  result
end