Class: Rails::SecretKeyGenerator
- Defined in:
- lib/rails_generator/secret_key_generator.rb
Overview
A class for creating random secret keys. This class will do its best to create a random secret key that’s as secure as possible, using whatever methods are available on the current platform. For example:
generator = Rails::SecretKeyGenerator("some unique identifier, such as the application name")
generator.generate_secret # => "f3f1be90053fa851... (some long string)"
This class is deprecated in Rails 2.2 in favor of ActiveSupport::SecureRandom. It is currently a wrapper around ActiveSupport::SecureRandom.
Instance Method Summary collapse
-
#generate_secret ⇒ Object
Generate a random secret key with the best possible method available on the current platform.
-
#initialize(identifier) ⇒ SecretKeyGenerator
constructor
A new instance of SecretKeyGenerator.
Constructor Details
#initialize(identifier) ⇒ SecretKeyGenerator
Returns a new instance of SecretKeyGenerator.
14 15 |
# File 'lib/rails_generator/secret_key_generator.rb', line 14 def initialize(identifier) end |
Instance Method Details
#generate_secret ⇒ Object
Generate a random secret key with the best possible method available on the current platform.
19 20 21 |
# File 'lib/rails_generator/secret_key_generator.rb', line 19 def generate_secret ActiveSupport::SecureRandom.hex(64) end |