diff options
author | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-12-03 19:30:35 +0100 |
---|---|---|
committer | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-12-03 19:30:35 +0100 |
commit | ccb96f2297e8783165cba764e9b5d51e1a15ff87 (patch) | |
tree | 3229e6fdddc42054615514d843c555e341003033 /activesupport/lib/active_support/secure_random.rb | |
parent | fb2325e35855d62abd2c76ce03feaa3ca7992e4f (diff) | |
parent | 761a633a9c0a45d76ef3ed10da97e3696c3ded79 (diff) | |
download | rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.tar.gz rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.tar.bz2 rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.zip |
Merge commit 'origin/master' into savepoints
Conflicts:
activerecord/lib/active_record/fixtures.rb
activerecord/test/cases/defaults_test.rb
Diffstat (limited to 'activesupport/lib/active_support/secure_random.rb')
-rw-r--r-- | activesupport/lib/active_support/secure_random.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/secure_random.rb b/activesupport/lib/active_support/secure_random.rb index 97971e8830..cfbce4d754 100644 --- a/activesupport/lib/active_support/secure_random.rb +++ b/activesupport/lib/active_support/secure_random.rb @@ -1,16 +1,11 @@ begin - require 'openssl' -rescue LoadError -end - -begin require 'securerandom' rescue LoadError end module ActiveSupport if defined?(::SecureRandom) - # Use Ruby 1.9's SecureRandom library whenever possible. + # Use Ruby's SecureRandom library if available. SecureRandom = ::SecureRandom # :nodoc: else # = Secure random number generator interface. @@ -64,6 +59,13 @@ module ActiveSupport def self.random_bytes(n=nil) n ||= 16 + unless defined? OpenSSL + begin + require 'openssl' + rescue LoadError + end + end + if defined? OpenSSL::Random return OpenSSL::Random.random_bytes(n) end |