diff options
author | Michael Koziarski <michael@koziarski.com> | 2013-04-18 16:13:11 -0700 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2013-04-18 16:13:11 -0700 |
commit | 30f9237b8eb4e445f5e1ce898581dff6675c28ee (patch) | |
tree | f496c09b27181be93ae029c05c5fedba82b23d3f /activesupport/lib | |
parent | e62f4404cf35e1606def6853b4450068f0ebc2cb (diff) | |
parent | 91a0a1156e622cad5221f33e852c19aa8eba6cbf (diff) | |
download | rails-30f9237b8eb4e445f5e1ce898581dff6675c28ee.tar.gz rails-30f9237b8eb4e445f5e1ce898581dff6675c28ee.tar.bz2 rails-30f9237b8eb4e445f5e1ce898581dff6675c28ee.zip |
Merge pull request #10235 from joergleis/patch-1
Reorganize MessageEncryptor
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/message_encryptor.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index ce40a7d689..96025e7614 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -28,7 +28,7 @@ module ActiveSupport end class InvalidMessage < StandardError; end - OpenSSLCipherError = OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError + OpenSSLCipherError = OpenSSL::Cipher::CipherError # Initialize a new MessageEncryptor. +secret+ must be at least as long as # the cipher key size. For the default 'aes-256-cbc' cipher, this is 256 @@ -66,12 +66,11 @@ module ActiveSupport def _encrypt(value) cipher = new_cipher - # Rely on OpenSSL for the initialization vector - iv = cipher.random_iv - cipher.encrypt cipher.key = @secret - cipher.iv = iv + + # Rely on OpenSSL for the initialization vector + iv = cipher.random_iv encrypted_data = cipher.update(@serializer.dump(value)) encrypted_data << cipher.final |