Method: ActiveSupport::MessageEncryptor#decrypt_and_verify
- Defined in:
- activesupport/lib/active_support/message_encryptor.rb
#decrypt_and_verify(message, **options) ⇒ Object
Decrypt and verify a message. We need to verify the message in order to avoid padding attacks. Reference: www.limited-entropy.com/padding-oracle-attacks/.
Options
:purpose-
The purpose that the message was generated with. If the purpose does not match,
decrypt_and_verifywill returnnil.= encryptor.encrypt_and_sign("hello", purpose: "greeting") encryptor.decrypt_and_verify(, purpose: "greeting") # => "hello" encryptor.decrypt_and_verify() # => nil = encryptor.encrypt_and_sign("bye") encryptor.decrypt_and_verify() # => "bye" encryptor.decrypt_and_verify(, purpose: "greeting") # => nil
241 242 243 244 245 246 247 248 249 |
# File 'activesupport/lib/active_support/message_encryptor.rb', line 241 def decrypt_and_verify(, **) catch_and_raise :invalid_message_format, as: InvalidMessage do catch_and_raise :invalid_message_serialization, as: InvalidMessage do catch_and_ignore :invalid_message_content do (, **) end end end end |