Method: SymmetricEncryption.try_decrypt

Defined in:
lib/symmetric_encryption/symmetric_encryption.rb

.try_decrypt(str) ⇒ Object

Invokes decrypt

Returns decrypted String
Return nil if it fails to decrypt a String

Useful for example when decoding passwords encrypted using a key from a different environment. I.e. We cannot decode production passwords in the test or development environments but still need to be able to load YAML config files that contain encrypted development and production passwords

WARNING: It is possible to decrypt data using the wrong key, so the value

returned should not be relied upon


238
239
240
241
242
# File 'lib/symmetric_encryption/symmetric_encryption.rb', line 238

def self.try_decrypt(str)
  decrypt(str)
rescue OpenSSL::Cipher::CipherError, SymmetricEncryption::CipherError
  nil
end