class ActiveSupport::MessageEncryptor
def decrypt_and_verify(message, **options)
encryptor.decrypt_and_verify(message, purpose: "greeting") # => nil
encryptor.decrypt_and_verify(message) # => "bye"
message = encryptor.encrypt_and_sign("bye")
encryptor.decrypt_and_verify(message) # => nil
encryptor.decrypt_and_verify(message, purpose: "greeting") # => "hello"
message = encryptor.encrypt_and_sign("hello", purpose: "greeting")
match, +decrypt_and_verify+ will return +nil+.
The purpose that the message was generated with. If the purpose does not
[+:purpose+]
==== Options
avoid padding attacks. Reference: https://www.limited-entropy.com/padding-oracle-attacks/.
Decrypt and verify a message. We need to verify the message in order to
def decrypt_and_verify(message, **options) 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 read_message(message, **options) end end end end