Module: Desviar::EncryptedItem::Encryptor
- Defined in:
- lib/encrypt.rb
Overview
Implementation class for converting plaintext data bag item values to an encrypted value, including any necessary wrappers and metadata.
Defined Under Namespace
Classes: Version1Encryptor, Version2Encryptor
Class Method Summary collapse
-
.new(value, secret, iv = nil, version = 2) ⇒ Object
“factory” method that creates an encryptor object with the proper class for the desired encrypted data bag format version.
Class Method Details
.new(value, secret, iv = nil, version = 2) ⇒ Object
“factory” method that creates an encryptor object with the proper class for the desired encrypted data bag format version.
Chef::Config[:data_bag_encrypt_version]
determines which version is used.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/encrypt.rb', line 74 def self.new(value, secret, iv=nil, version=2) format_version = version case format_version when 1 Version1Encryptor.new(value, secret, iv) when 2 Version2Encryptor.new(value, secret, iv) else raise UnsupportedEncryptedDataBagItemFormat, "Invalid encrypted data bag format version `#{format_version}'. Supported versions are '1', '2'" end end |