-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
require 'securerandom'
arr = []
(1..100).each do |i|
r = SecureRandom.random_number(10)
puts "#{i}: #{r}"
arr << r
end
puts arr.uniq
# there might still be the one case in the
# universe where we would have a 100times the
# same number. But it's probably fine as an
# indication...
exit (arr.uniq.length > 1 ? 0 : 1)Always returns 0.
According to @headius
It appears to be a bug in some very old code used to generate a random int or long by calling bytes on the self object, but it does not handle the bit math properly to produce the final value. This logic was not in use for SecureRandom until we moved to the securerandom gem, which depends on these callbacks to work properly.
See ruby/setup-ruby#448 & duritong/trocla#75 for more background
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels