Method: ActiveRecord::Encryption::Encryptor#decrypt
- Defined in:
- lib/active_record/encryption/encryptor.rb
#decrypt(encrypted_text, key_provider: default_key_provider, cipher_options: {}) ⇒ Object
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_provider
when not provided - :cipher_options
-
Cipher-specific options that will be passed to the Cipher configured in
ActiveRecord::Encryption.cipher
67 68 69 70 71 72 73 74 |
# File 'lib/active_record/encryption/encryptor.rb', line 67 def decrypt(encrypted_text, key_provider: default_key_provider, cipher_options: {}) = (encrypted_text) keys = key_provider.decryption_keys() raise Errors::Decryption unless keys.present? uncompress_if_needed(cipher.decrypt(, key: keys.collect(&:secret), **), .headers.compressed) rescue *(ENCODING_ERRORS + DECRYPT_ERRORS) raise Errors::Decryption end |