instance method
decrypt
Ruby on Rails 8.1.2
Since v7.0.10Signature
decrypt(encrypted_text, key_provider: default_key_provider, cipher_options: {})
Decrypts an encrypted_text and returns the result as clean text.
Options
:key_provider-
Key provider to use for the encryption operation. It will default to
ActiveRecord::Encryption.key_providerwhen not provided. :cipher_options-
Cipher-specific options that will be passed to the Cipher configured in
ActiveRecord::Encryption.cipher.
Parameters
-
encrypted_textreq -
key_providerkey = default_key_provider -
cipher_optionskey = {}
Source
# File activerecord/lib/active_record/encryption/encryptor.rb, line 69
def decrypt(encrypted_text, key_provider: default_key_provider, cipher_options: {})
message = deserialize_message(encrypted_text)
keys = key_provider.decryption_keys(message)
raise Errors::Decryption unless keys.present?
uncompress_if_needed(cipher.decrypt(message, key: keys.collect(&:secret), **cipher_options), message.headers.compressed)
rescue *(ENCODING_ERRORS + DECRYPT_ERRORS)
raise Errors::Decryption
end
Defined in activerecord/lib/active_record/encryption/encryptor.rb line 69
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Encryption::Encryptor