2007-11-28 14:36:59 -05:00
|
|
|
module Rails
|
2008-02-09 17:18:38 -05:00
|
|
|
# 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)"
|
2008-08-27 06:42:08 -04:00
|
|
|
#
|
|
|
|
# This class is *deprecated* in Rails 2.2 in favor of ActiveSupport::SecureRandom.
|
|
|
|
# It is currently a wrapper around ActiveSupport::SecureRandom.
|
2007-11-28 14:36:59 -05:00
|
|
|
class SecretKeyGenerator
|
|
|
|
def initialize(identifier)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Generate a random secret key with the best possible method available on
|
|
|
|
# the current platform.
|
|
|
|
def generate_secret
|
2008-08-27 06:42:08 -04:00
|
|
|
ActiveSupport::SecureRandom.hex(64)
|
2007-11-28 14:36:59 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|