diff options
author | Matthew Draper <matthew@trebex.net> | 2016-09-01 07:49:55 +0930 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-01 07:49:55 +0930 |
commit | df63c0d8c94472e941ce515ea546f75f5047696b (patch) | |
tree | d330726952e6e5a8175a0144cf7de4d272703aea /activesupport/lib/active_support | |
parent | fd2446cd8156f288598cdb47172cfe31ec24c1ee (diff) | |
parent | 79c847892f5a08515769ad2598d4e6726dcd65e3 (diff) | |
download | rails-df63c0d8c94472e941ce515ea546f75f5047696b.tar.gz rails-df63c0d8c94472e941ce515ea546f75f5047696b.tar.bz2 rails-df63c0d8c94472e941ce515ea546f75f5047696b.zip |
Merge pull request #25758 from vipulnsward/fix-key-len-issue
Follow up of #25602
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/message_encryptor.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index ab8b2f8ded..7b33dc3481 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -19,6 +19,8 @@ module ActiveSupport # encrypted_data = crypt.encrypt_and_sign('my secret data') # => "NlFBTTMwOUV5UlA1QlNEN2xkY2d6eThYWWh..." # crypt.decrypt_and_verify(encrypted_data) # => "my secret data" class MessageEncryptor + DEFAULT_CIPHER = "aes-256-cbc" + module NullSerializer #:nodoc: def self.load(value) value @@ -77,6 +79,11 @@ module ActiveSupport _decrypt(verifier.verify(value)) end + # Given a cipher, returns the key length of the cipher to help generate the key of desired size + def self.key_len(cipher = DEFAULT_CIPHER) + OpenSSL::Cipher.new(cipher).key_len + end + private def _encrypt(value) |