# module Chef::EncryptedDataBagItem::Encryptor

Implementation class for converting plaintext data bag item values to an encrypted value, including any necessary wrappers and metadata.

### Public Class Methods

new(value, secret, iv=nil) click to toggle source

“factory” method that creates an encryptor object with the proper class for the desired encrypted data bag format version.

+Chef::Config+ determines which version is used.

    # File lib/chef/encrypted_data_bag_item/encryptor.rb, line 36
    def self.new(value, secret, iv=nil)
      format_version = Chef::Config[:data_bag_encrypt_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