aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2017-01-04 23:54:03 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2017-01-04 23:54:03 -0500
commit46bb76acadc132de0344166db223be5f3fcd5426 (patch)
tree1e60e96f8077f432d53bb0342f6eeab41953405c /activesupport
parentd66789fa0e3ac589f06feb735a3451fb4d9405fc (diff)
downloadrails-46bb76acadc132de0344166db223be5f3fcd5426.tar.gz
rails-46bb76acadc132de0344166db223be5f3fcd5426.tar.bz2
rails-46bb76acadc132de0344166db223be5f3fcd5426.zip
Make sure we generate keys that can be used with the cipher
We use aes-256-cbc cipher by default and it only accepts keys with 32 bytes at max. Closes #27576. [ci skip]
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/message_encryptor.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb
index 7b33dc3481..0671469788 100644
--- a/activesupport/lib/active_support/message_encryptor.rb
+++ b/activesupport/lib/active_support/message_encryptor.rb
@@ -14,10 +14,10 @@ module ActiveSupport
# where you don't want users to be able to determine the value of the payload.
#
# salt = SecureRandom.random_bytes(64)
- # key = ActiveSupport::KeyGenerator.new('password').generate_key(salt) # => "\x89\xE0\x156\xAC..."
- # crypt = ActiveSupport::MessageEncryptor.new(key) # => #<ActiveSupport::MessageEncryptor ...>
- # encrypted_data = crypt.encrypt_and_sign('my secret data') # => "NlFBTTMwOUV5UlA1QlNEN2xkY2d6eThYWWh..."
- # crypt.decrypt_and_verify(encrypted_data) # => "my secret data"
+ # key = ActiveSupport::KeyGenerator.new('password').generate_key(salt, 32) # => "\x89\xE0\x156\xAC..."
+ # crypt = ActiveSupport::MessageEncryptor.new(key) # => #<ActiveSupport::MessageEncryptor ...>
+ # 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"