~michaelforrest/use-case-mapper/trunk

« back to all changes in this revision

Viewing changes to vendor/rails/railties/lib/rails_generator/secret_key_generator.rb

  • Committer: Richard Lee (Canonical)
  • Date: 2010-10-15 15:17:58 UTC
  • mfrom: (190.1.3 use-case-mapper)
  • Revision ID: richard.lee@canonical.com-20101015151758-wcvmfxrexsongf9d
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
require 'active_support/deprecation'
2
 
 
3
 
module Rails
4
 
  # A class for creating random secret keys. This class will do its best to create a
5
 
  # random secret key that's as secure as possible, using whatever methods are
6
 
  # available on the current platform. For example:
7
 
  #
8
 
  #   generator = Rails::SecretKeyGenerator("some unique identifier, such as the application name")
9
 
  #   generator.generate_secret     # => "f3f1be90053fa851... (some long string)"
10
 
  #
11
 
  # This class is *deprecated* in Rails 2.2 in favor of ActiveSupport::SecureRandom.
12
 
  # It is currently a wrapper around ActiveSupport::SecureRandom.
13
 
  class SecretKeyGenerator
14
 
    def initialize(identifier)
15
 
    end
16
 
 
17
 
    # Generate a random secret key with the best possible method available on
18
 
    # the current platform.
19
 
    def generate_secret
20
 
      ActiveSupport::SecureRandom.hex(64)
21
 
    end
22
 
    deprecate :generate_secret=>"You should use ActiveSupport::SecureRandom.hex(64)"
23
 
  end
24
 
end