diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-11-15 23:06:44 -0200 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2012-11-15 23:06:44 -0200 |
commit | e6e3317c5409b069782e7b701a11bcd5283794ae (patch) | |
tree | 396cb6360bf969d3050bdb91107f28e94183d80d | |
parent | d348c43c1cd6db153410514026a58e2bb2b07095 (diff) | |
download | rails-e6e3317c5409b069782e7b701a11bcd5283794ae.tar.gz rails-e6e3317c5409b069782e7b701a11bcd5283794ae.tar.bz2 rails-e6e3317c5409b069782e7b701a11bcd5283794ae.zip |
Add docs for CachingKeyGenerator
-rw-r--r-- | activesupport/lib/active_support/key_generator.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/key_generator.rb b/activesupport/lib/active_support/key_generator.rb index a79bab816a..6beb2b6afa 100644 --- a/activesupport/lib/active_support/key_generator.rb +++ b/activesupport/lib/active_support/key_generator.rb @@ -22,12 +22,18 @@ module ActiveSupport end end + # CachingKeyGenerator is a wrapper around KeyGenerator which allows users to avoid + # re-executing the key generation process when it's called using the same salt and + # key_size class CachingKeyGenerator def initialize(key_generator) @key_generator = key_generator @cache_keys = {}.extend(Mutex_m) end + # Returns a derived key suitable for use. The default key_size is chosen + # to be compatible with the default settings of ActiveSupport::MessageVerifier. + # i.e. OpenSSL::Digest::SHA1#block_length def generate_key(salt, key_size=64) @cache_keys.synchronize do @cache_keys["#{salt}#{key_size}"] ||= @key_generator.generate_key(salt, key_size) |