diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-04-21 19:49:16 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-04-21 19:49:16 -0500 |
commit | 0a94f16b9532894aeb7aed2aec5082dd3b521414 (patch) | |
tree | 0009b22e18c3f27740bea5d42f93c60a54678d2c /railties/lib | |
parent | de8b0087c61af6c8b1cab7c1760f2e326b996702 (diff) | |
download | rails-0a94f16b9532894aeb7aed2aec5082dd3b521414.tar.gz rails-0a94f16b9532894aeb7aed2aec5082dd3b521414.tar.bz2 rails-0a94f16b9532894aeb7aed2aec5082dd3b521414.zip |
Fallback to Ruby's pseudo random number generator if the system does not have SHA512 installed.
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails_generator/secret_key_generator.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/railties/lib/rails_generator/secret_key_generator.rb b/railties/lib/rails_generator/secret_key_generator.rb index 801b33c761..64fbbb90f8 100644 --- a/railties/lib/rails_generator/secret_key_generator.rb +++ b/railties/lib/rails_generator/secret_key_generator.rb @@ -76,7 +76,12 @@ module Rails OpenSSL::Random.seed(rand(0).to_s + Time.now.usec.to_s) end data = OpenSSL::BN.rand(2048, -1, false).to_s - return OpenSSL::Digest::SHA512.new(data).hexdigest + + if OpenSSL::OPENSSL_VERSION_NUMBER > 0x00908000 + OpenSSL::Digest::SHA512.new(data).hexdigest + else + generate_secret_with_prng + end end # Generate a random secret key with /dev/urandom. |