Method: SymmetricEncryption.cipher
- Defined in:
- lib/symmetric_encryption/symmetric_encryption.rb
.cipher(version = nil) ⇒ Object
Returns the Primary Symmetric Cipher being used If a version is supplied
Returns the primary cipher if no match was found and version == 0
Returns nil if no match was found and version != 0
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/symmetric_encryption/symmetric_encryption.rb', line 46 def self.cipher(version = nil) unless cipher? raise( SymmetricEncryption::ConfigError, "Call SymmetricEncryption.load! or SymmetricEncryption.cipher= prior to encrypting or decrypting data" ) end return @cipher if version.nil? || (@cipher.version == version) secondary_ciphers.find { |c| c.version == version } || (@cipher if version.zero?) end |