News for hackers. Stuff that matters.
Re:Ruby Bug: SecureRandom should try /dev/urandom first by wrs on Wednesday May 04, 2016 @12:55AM (#11626285)
To make this discussion really useful: what's the easiest way for a Ruby application to make SecureRandom use /dev/urandom, without waiting for Ruby-core to be convinced?
Re:Ruby Bug: SecureRandom should try /dev/urandom first by infraruby on Wednesday May 04, 2016 @09:01AM (#11627989)

  require "securerandom"

  module SecureRandom
    F = File.open("/dev/urandom")

    def self.random_bytes(n = nil)
      F.read(n || 16)
    end
  end
Re:Ruby Bug: SecureRandom should try /dev/urandom first by goldbrick on Wednesday May 04, 2016 @10:18AM (#11628510)
Why not just make the argument default to 16? Is something non-obvious going on?
Re:Ruby Bug: SecureRandom should try /dev/urandom first by infraruby on Wednesday May 04, 2016 @10:32AM (#11628608)
The caller may pass nil explicitly.
Re:Ruby Bug: SecureRandom should try /dev/urandom first by goldbrick on Wednesday May 04, 2016 @12:57PM (#11629698)
I don't understand. You may still pass nil explicitly if the argument defaults to 16?
Re:Ruby Bug: SecureRandom should try /dev/urandom first by infraruby on Wednesday May 04, 2016 @03:22PM (#11630966)
Yes:

  def f(n = 16)
    n
  end

  p f # => 16
  p f(nil) # => nil