Project

General

Profile

Bug #6799 » secure_random.patch

tenderlovemaking (Aaron Patterson), 09/06/2012 08:58 AM

View differences:

lib/securerandom.rb
# If secure random number generator is not available,
# NotImplementedError is raised.
def self.hex(n=nil)
random_bytes(n).unpack("H*")[0]
random_bytes(n).unpack("H*")[0].force_encoding(Encoding::US_ASCII)
end
# SecureRandom.base64 generates a random base64 string.
test/test_securerandom.rb
end
end
def test_hex_encoding
assert_equal(Encoding::US_ASCII, @it.hex.encoding)
end
def test_s_base64
assert_equal(16, @it.base64.unpack('m*')[0].size)
17.times do |idx|
(3-3/4)