From e6e3317c5409b069782e7b701a11bcd5283794ae Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 15 Nov 2012 23:06:44 -0200 Subject: Add docs for CachingKeyGenerator --- activesupport/lib/active_support/key_generator.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activesupport/lib/active_support') 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) -- cgit v1.2.3